2007-06-26 19:33:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
generate_mock_once('HTMLPurifier_ErrorCollector');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extended error collector mock that has the ability to expect context
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_ErrorCollectorEMock extends HTMLPurifier_ErrorCollectorMock
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-11-25 02:24:39 +00:00
|
|
|
private $_context;
|
|
|
|
private $_expected_context = array();
|
|
|
|
private $_expected_context_at = array();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function prepare($context)
|
|
|
|
{
|
2008-04-28 19:52:13 +00:00
|
|
|
$this->_context = $context;
|
2007-06-26 19:33:37 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function expectContext($key, $value)
|
|
|
|
{
|
2007-06-26 19:33:37 +00:00
|
|
|
$this->_expected_context[$key] = $value;
|
|
|
|
}
|
2013-07-16 11:56:14 +00:00
|
|
|
public function expectContextAt($step, $key, $value)
|
|
|
|
{
|
2007-06-26 19:33:37 +00:00
|
|
|
$this->_expected_context_at[$step][$key] = $value;
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function send($v1, $v2)
|
|
|
|
{
|
2007-06-26 19:33:37 +00:00
|
|
|
// test for context
|
2008-04-14 03:06:36 +00:00
|
|
|
$context = SimpleTest::getContext();
|
|
|
|
$test = $context->getTest();
|
2008-04-28 19:52:13 +00:00
|
|
|
$mock = $this->mock;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-26 19:33:37 +00:00
|
|
|
foreach ($this->_expected_context as $key => $value) {
|
|
|
|
$test->assertEqual($value, $this->_context->get($key));
|
|
|
|
}
|
2007-11-05 05:01:51 +00:00
|
|
|
$step = $mock->getCallCount('send');
|
2007-06-26 19:33:37 +00:00
|
|
|
if (isset($this->_expected_context_at[$step])) {
|
|
|
|
foreach ($this->_expected_context_at[$step] as $key => $value) {
|
|
|
|
$test->assertEqual($value, $this->_context->get($key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// boilerplate mock code, does not have return value or references
|
|
|
|
$args = func_get_args();
|
2008-04-26 03:18:07 +00:00
|
|
|
$mock->invoke('send', $args);
|
2007-06-26 19:33:37 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-26 19:33:37 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|