Fix autoparagraph bug with non-inline elements.
[htmlpurifier.git] / tests / HTMLPurifier / Strategy / CompositeTest.php
blob8be422cc97b9123a35edc9fb0438f940553531da
1 <?php
3 class HTMLPurifier_Strategy_Composite_Test
4 extends HTMLPurifier_Strategy_Composite
7 public function __construct(&$strategies) {
8 $this->strategies =& $strategies;
13 // doesn't use Strategy harness
14 class HTMLPurifier_Strategy_CompositeTest extends HTMLPurifier_Harness
17 function test() {
19 generate_mock_once('HTMLPurifier_Strategy');
20 generate_mock_once('HTMLPurifier_Config');
21 generate_mock_once('HTMLPurifier_Context');
23 // setup a bunch of mock strategies to inject into our composite test
25 $mock_1 = new HTMLPurifier_StrategyMock();
26 $mock_2 = new HTMLPurifier_StrategyMock();
27 $mock_3 = new HTMLPurifier_StrategyMock();
29 // setup the object
31 $strategies = array(&$mock_1, &$mock_2, &$mock_3);
32 $composite = new HTMLPurifier_Strategy_Composite_Test($strategies);
34 // setup expectations
36 $input_1 = 'This is raw data';
37 $input_2 = 'Processed by 1';
38 $input_3 = 'Processed by 1 and 2';
39 $input_4 = 'Processed by 1, 2 and 3'; // expected output
41 $config = new HTMLPurifier_ConfigMock();
42 $context = new HTMLPurifier_ContextMock();
44 $params_1 = array($input_1, $config, $context);
45 $params_2 = array($input_2, $config, $context);
46 $params_3 = array($input_3, $config, $context);
48 $mock_1->expectOnce('execute', $params_1);
49 $mock_1->setReturnValue('execute', $input_2, $params_1);
51 $mock_2->expectOnce('execute', $params_2);
52 $mock_2->setReturnValue('execute', $input_3, $params_2);
54 $mock_3->expectOnce('execute', $params_3);
55 $mock_3->setReturnValue('execute', $input_4, $params_3);
57 // perform test
59 $output = $composite->execute($input_1, $config, $context);
60 $this->assertIdentical($input_4, $output);
66 // vim: et sw=4 sts=4