mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 16:59:55 +09:00
merge from 1.6 ( html purifier lib )
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10579 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
8943ff97f3
commit
7ea7157ce7
813 changed files with 65203 additions and 0 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue