Add vim modelines to all files.
[htmlpurifier.git] / tests / HTMLPurifier / ErrorCollectorEMock.php
blobbbd0965694c61a5bca3041c6ea12fe364808f8d3
1 <?php
3 generate_mock_once('HTMLPurifier_ErrorCollector');
5 /**
6 * Extended error collector mock that has the ability to expect context
7 */
8 class HTMLPurifier_ErrorCollectorEMock extends HTMLPurifier_ErrorCollectorMock
11 private $_context;
12 private $_expected_context = array();
13 private $_expected_context_at = array();
15 public function prepare($context) {
16 $this->_context = $context;
19 public function expectContext($key, $value) {
20 $this->_expected_context[$key] = $value;
22 public function expectContextAt($step, $key, $value) {
23 $this->_expected_context_at[$step][$key] = $value;
26 public function send($v1, $v2) {
27 // test for context
28 $context = SimpleTest::getContext();
29 $test = $context->getTest();
30 $mock = $this->mock;
32 foreach ($this->_expected_context as $key => $value) {
33 $test->assertEqual($value, $this->_context->get($key));
35 $step = $mock->getCallCount('send');
36 if (isset($this->_expected_context_at[$step])) {
37 foreach ($this->_expected_context_at[$step] as $key => $value) {
38 $test->assertEqual($value, $this->_context->get($key));
41 // boilerplate mock code, does not have return value or references
42 $args = func_get_args();
43 $mock->invoke('send', $args);
48 // vim: et sw=4 sts=4