Release 2.0.1, merged in 1181 to HEAD.
[htmlpurifier.git] / tests / HTMLPurifier / DefinitionCache / Decorator / CleanupTest.php
blobdc60752aeb4529c8b2f4c3939be847284ea738b6
1 <?php
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
11 function setup() {
12 $this->cache = new HTMLPurifier_DefinitionCache_Decorator_Cleanup();
13 parent::setup();
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));
28 function test_get() {
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);
42 function test_set() {
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);
52 function test_add() {
53 $this->setupMockForSuccess('add');
54 $this->assertEqual($this->cache->add($this->def, $this->config), true);