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.

68 lines
1.9KB

  1. <?php
  2. class HTMLPurifier_Strategy_Composite_Test
  3. extends HTMLPurifier_Strategy_Composite
  4. {
  5. public function __construct(&$strategies)
  6. {
  7. $this->strategies =& $strategies;
  8. }
  9. }
  10. // doesn't use Strategy harness
  11. class HTMLPurifier_Strategy_CompositeTest extends HTMLPurifier_Harness
  12. {
  13. public function test()
  14. {
  15. generate_mock_once('HTMLPurifier_Strategy');
  16. generate_mock_once('HTMLPurifier_Config');
  17. generate_mock_once('HTMLPurifier_Context');
  18. // setup a bunch of mock strategies to inject into our composite test
  19. $mock_1 = new HTMLPurifier_StrategyMock();
  20. $mock_2 = new HTMLPurifier_StrategyMock();
  21. $mock_3 = new HTMLPurifier_StrategyMock();
  22. // setup the object
  23. $strategies = array(&$mock_1, &$mock_2, &$mock_3);
  24. $composite = new HTMLPurifier_Strategy_Composite_Test($strategies);
  25. // setup expectations
  26. $input_1 = 'This is raw data';
  27. $input_2 = 'Processed by 1';
  28. $input_3 = 'Processed by 1 and 2';
  29. $input_4 = 'Processed by 1, 2 and 3'; // expected output
  30. $config = new HTMLPurifier_ConfigMock();
  31. $context = new HTMLPurifier_ContextMock();
  32. $params_1 = array($input_1, $config, $context);
  33. $params_2 = array($input_2, $config, $context);
  34. $params_3 = array($input_3, $config, $context);
  35. $mock_1->expectOnce('execute', $params_1);
  36. $mock_1->setReturnValue('execute', $input_2, $params_1);
  37. $mock_2->expectOnce('execute', $params_2);
  38. $mock_2->setReturnValue('execute', $input_3, $params_2);
  39. $mock_3->expectOnce('execute', $params_3);
  40. $mock_3->setReturnValue('execute', $input_4, $params_3);
  41. // perform test
  42. $output = $composite->execute($input_1, $config, $context);
  43. $this->assertIdentical($input_4, $output);
  44. }
  45. }
  46. // vim: et sw=4 sts=4