You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4KB

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