3 generate_mock_once('HTMLPurifier_DefinitionCache');
5 class HTMLPurifier_DefinitionCache_Decorator_CleanupTest
extends HTMLPurifier_DefinitionCache_DecoratorHarness
8 public function setup()
10 $this->cache
= new HTMLPurifier_DefinitionCache_Decorator_Cleanup();
14 public function setupMockForSuccess($op)
16 $this->mock
->expectOnce($op, array($this->def
, $this->config
));
17 $this->mock
->returns($op, true, array($this->def
, $this->config
));
18 $this->mock
->expectNever('cleanup');
21 public function setupMockForFailure($op)
23 $this->mock
->expectOnce($op, array($this->def
, $this->config
));
24 $this->mock
->returns($op, false, array($this->def
, $this->config
));
25 $this->mock
->expectOnce('cleanup', array($this->config
));
28 public function test_get()
30 $this->mock
->expectOnce('get', array($this->config
));
31 $this->mock
->returns('get', true, array($this->config
));
32 $this->mock
->expectNever('cleanup');
33 $this->assertEqual($this->cache
->get($this->config
), $this->def
);
36 public function test_get_failure()
38 $this->mock
->expectOnce('get', array($this->config
));
39 $this->mock
->returns('get', false, array($this->config
));
40 $this->mock
->expectOnce('cleanup', array($this->config
));
41 $this->assertEqual($this->cache
->get($this->config
), false);
44 public function test_set()
46 $this->setupMockForSuccess('set');
47 $this->assertEqual($this->cache
->set($this->def
, $this->config
), true);
50 public function test_replace()
52 $this->setupMockForSuccess('replace');
53 $this->assertEqual($this->cache
->replace($this->def
, $this->config
), true);
56 public function test_add()
58 $this->setupMockForSuccess('add');
59 $this->assertEqual($this->cache
->add($this->def
, $this->config
), true);