3 generate_mock_once('HTMLPurifier_DefinitionCache');
5 class HTMLPurifier_DefinitionCache_Decorator_CleanupTest
extends HTMLPurifier_DefinitionCache_DecoratorHarness
9 $this->cache
= new HTMLPurifier_DefinitionCache_Decorator_Cleanup();
13 function setupMockForSuccess($op) {
14 $this->mock
->expectOnce($op, array($this->def
, $this->config
));
15 $this->mock
->setReturnValue($op, true, array($this->def
, $this->config
));
16 $this->mock
->expectNever('cleanup');
19 function setupMockForFailure($op) {
20 $this->mock
->expectOnce($op, array($this->def
, $this->config
));
21 $this->mock
->setReturnValue($op, false, array($this->def
, $this->config
));
22 $this->mock
->expectOnce('cleanup', array($this->config
));
26 $this->mock
->expectOnce('get', array($this->config
));
27 $this->mock
->setReturnValue('get', true, array($this->config
));
28 $this->mock
->expectNever('cleanup');
29 $this->assertEqual($this->cache
->get($this->config
), $this->def
);
32 function test_get_failure() {
33 $this->mock
->expectOnce('get', array($this->config
));
34 $this->mock
->setReturnValue('get', false, array($this->config
));
35 $this->mock
->expectOnce('cleanup', array($this->config
));
36 $this->assertEqual($this->cache
->get($this->config
), false);
40 $this->setupMockForSuccess('set');
41 $this->assertEqual($this->cache
->set($this->def
, $this->config
), true);
44 function test_replace() {
45 $this->setupMockForSuccess('replace');
46 $this->assertEqual($this->cache
->replace($this->def
, $this->config
), true);
50 $this->setupMockForSuccess('add');
51 $this->assertEqual($this->cache
->add($this->def
, $this->config
), true);