diff options
author | friendica <info@friendica.com> | 2012-05-12 17:57:41 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-07-18 20:40:31 +1000 |
commit | 7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a (patch) | |
tree | a9c3d91209cff770bb4b613b1b95e61a7bbc5a2b /lib/htmlpurifier/tests/HTMLPurifier/DefinitionCacheFactoryTest.php | |
parent | cd727cb26b78a1dade09d510b071446898477356 (diff) | |
download | volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.gz volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.bz2 volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.zip |
some important stuff we'll need
Diffstat (limited to 'lib/htmlpurifier/tests/HTMLPurifier/DefinitionCacheFactoryTest.php')
-rw-r--r-- | lib/htmlpurifier/tests/HTMLPurifier/DefinitionCacheFactoryTest.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/DefinitionCacheFactoryTest.php b/lib/htmlpurifier/tests/HTMLPurifier/DefinitionCacheFactoryTest.php new file mode 100644 index 000000000..d50ef8be1 --- /dev/null +++ b/lib/htmlpurifier/tests/HTMLPurifier/DefinitionCacheFactoryTest.php @@ -0,0 +1,70 @@ +<?php + +class HTMLPurifier_DefinitionCacheFactoryTest extends HTMLPurifier_Harness +{ + + protected $factory; + protected $oldFactory; + + public function setUp() { + parent::setup(); + $this->factory = new HTMLPurifier_DefinitionCacheFactory(); + $this->oldFactory = HTMLPurifier_DefinitionCacheFactory::instance(); + HTMLPurifier_DefinitionCacheFactory::instance($this->factory); + } + + public function tearDown() { + HTMLPurifier_DefinitionCacheFactory::instance($this->oldFactory); + } + + function test_create() { + $cache = $this->factory->create('Test', $this->config); + $this->assertEqual($cache, new HTMLPurifier_DefinitionCache_Serializer('Test')); + } + + function test_create_withDecorator() { + $this->factory->addDecorator('Memory'); + $cache = $this->factory->create('Test', $this->config); + $cache_real = new HTMLPurifier_DefinitionCache_Decorator_Memory(); + $cache_real = $cache_real->decorate(new HTMLPurifier_DefinitionCache_Serializer('Test')); + $this->assertEqual($cache, $cache_real); + } + + function test_create_withDecoratorObject() { + $this->factory->addDecorator(new HTMLPurifier_DefinitionCache_Decorator_Memory()); + $cache = $this->factory->create('Test', $this->config); + $cache_real = new HTMLPurifier_DefinitionCache_Decorator_Memory(); + $cache_real = $cache_real->decorate(new HTMLPurifier_DefinitionCache_Serializer('Test')); + $this->assertEqual($cache, $cache_real); + } + + function test_create_recycling() { + $cache = $this->factory->create('Test', $this->config); + $cache2 = $this->factory->create('Test', $this->config); + $this->assertReference($cache, $cache2); + } + + function test_create_invalid() { + $this->config->set('Cache.DefinitionImpl', 'Invalid'); + $this->expectError('Unrecognized DefinitionCache Invalid, using Serializer instead'); + $cache = $this->factory->create('Test', $this->config); + $this->assertIsA($cache, 'HTMLPurifier_DefinitionCache_Serializer'); + } + + function test_null() { + $this->config->set('Cache.DefinitionImpl', null); + $cache = $this->factory->create('Test', $this->config); + $this->assertEqual($cache, new HTMLPurifier_DefinitionCache_Null('Test')); + } + + function test_register() { + generate_mock_once('HTMLPurifier_DefinitionCache'); + $this->config->set('Cache.DefinitionImpl', 'TestCache'); + $this->factory->register('TestCache', $class = 'HTMLPurifier_DefinitionCacheMock'); + $cache = $this->factory->create('Test', $this->config); + $this->assertIsA($cache, $class); + } + +} + +// vim: et sw=4 sts=4 |