3 require_once 'HTMLPurifier/DefinitionCache/DecoratorHarness.php';
4 require_once 'HTMLPurifier/DefinitionCache/Decorator/Cleanup.php';
6 generate_mock_once('HTMLPurifier_DefinitionCache');
8 class HTMLPurifier_DefinitionCache_Decorator_CleanupTest
extends HTMLPurifier_DefinitionCache_DecoratorHarness
12 $this->cache
= new HTMLPurifier_DefinitionCache_Decorator_Cleanup();
16 function setupMockForSuccess($op) {
17 $this->mock
->expectOnce($op, array($this->def
, $this->config
));
18 $this->mock
->setReturnValue($op, true, array($this->def
, $this->config
));
19 $this->mock
->expectNever('cleanup');
22 function setupMockForFailure($op) {
23 $this->mock
->expectOnce($op, array($this->def
, $this->config
));
24 $this->mock
->setReturnValue($op, false, array($this->def
, $this->config
));
25 $this->mock
->expectOnce('cleanup', array($this->config
));
29 $this->mock
->expectOnce('get', array($this->config
));
30 $this->mock
->setReturnValue('get', true, array($this->config
));
31 $this->mock
->expectNever('cleanup');
32 $this->assertEqual($this->cache
->get($this->config
), $this->def
);
35 function test_get_failure() {
36 $this->mock
->expectOnce('get', array($this->config
));
37 $this->mock
->setReturnValue('get', false, array($this->config
));
38 $this->mock
->expectOnce('cleanup', array($this->config
));
39 $this->assertEqual($this->cache
->get($this->config
), false);
43 $this->setupMockForSuccess('set');
44 $this->assertEqual($this->cache
->set($this->def
, $this->config
), true);
47 function test_replace() {
48 $this->setupMockForSuccess('replace');
49 $this->assertEqual($this->cache
->replace($this->def
, $this->config
), true);
53 $this->setupMockForSuccess('add');
54 $this->assertEqual($this->cache
->add($this->def
, $this->config
), true);