1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 21:57:26 +02:00

Remove trailing whitespace.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2008-12-06 02:28:20 -05:00
parent 3a6b63dff1
commit 2c955af135
476 changed files with 5595 additions and 5547 deletions

View File

@@ -4,52 +4,52 @@ generate_mock_once('HTMLPurifier_DefinitionCache');
class HTMLPurifier_DefinitionCache_Decorator_CleanupTest extends HTMLPurifier_DefinitionCache_DecoratorHarness
{
function setup() {
$this->cache = new HTMLPurifier_DefinitionCache_Decorator_Cleanup();
parent::setup();
}
function setupMockForSuccess($op) {
$this->mock->expectOnce($op, array($this->def, $this->config));
$this->mock->setReturnValue($op, true, array($this->def, $this->config));
$this->mock->expectNever('cleanup');
}
function setupMockForFailure($op) {
$this->mock->expectOnce($op, array($this->def, $this->config));
$this->mock->setReturnValue($op, false, array($this->def, $this->config));
$this->mock->expectOnce('cleanup', array($this->config));
}
function test_get() {
$this->mock->expectOnce('get', array($this->config));
$this->mock->setReturnValue('get', true, array($this->config));
$this->mock->expectNever('cleanup');
$this->assertEqual($this->cache->get($this->config), $this->def);
}
function test_get_failure() {
$this->mock->expectOnce('get', array($this->config));
$this->mock->setReturnValue('get', false, array($this->config));
$this->mock->expectOnce('cleanup', array($this->config));
$this->assertEqual($this->cache->get($this->config), false);
}
function test_set() {
$this->setupMockForSuccess('set');
$this->assertEqual($this->cache->set($this->def, $this->config), true);
}
function test_replace() {
$this->setupMockForSuccess('replace');
$this->assertEqual($this->cache->replace($this->def, $this->config), true);
}
function test_add() {
$this->setupMockForSuccess('add');
$this->assertEqual($this->cache->add($this->def, $this->config), true);
}
}

View File

@@ -4,66 +4,66 @@ generate_mock_once('HTMLPurifier_DefinitionCache');
class HTMLPurifier_DefinitionCache_Decorator_MemoryTest extends HTMLPurifier_DefinitionCache_DecoratorHarness
{
function setup() {
$this->cache = new HTMLPurifier_DefinitionCache_Decorator_Memory();
parent::setup();
}
function setupMockForSuccess($op) {
$this->mock->expectOnce($op, array($this->def, $this->config));
$this->mock->setReturnValue($op, true, array($this->def, $this->config));
$this->mock->expectNever('get');
}
function setupMockForFailure($op) {
$this->mock->expectOnce($op, array($this->def, $this->config));
$this->mock->setReturnValue($op, false, array($this->def, $this->config));
$this->mock->expectOnce('get', array($this->config));
}
function test_get() {
$this->mock->expectOnce('get', array($this->config)); // only ONE call!
$this->mock->setReturnValue('get', $this->def, array($this->config));
$this->assertEqual($this->cache->get($this->config), $this->def);
$this->assertEqual($this->cache->get($this->config), $this->def);
}
function test_set() {
$this->setupMockForSuccess('set', 'get');
$this->assertEqual($this->cache->set($this->def, $this->config), true);
$this->assertEqual($this->cache->get($this->config), $this->def);
}
function test_set_failure() {
$this->setupMockForFailure('set', 'get');
$this->assertEqual($this->cache->set($this->def, $this->config), false);
$this->cache->get($this->config);
}
function test_replace() {
$this->setupMockForSuccess('replace', 'get');
$this->assertEqual($this->cache->replace($this->def, $this->config), true);
$this->assertEqual($this->cache->get($this->config), $this->def);
}
function test_replace_failure() {
$this->setupMockForFailure('replace', 'get');
$this->assertEqual($this->cache->replace($this->def, $this->config), false);
$this->cache->get($this->config);
}
function test_add() {
$this->setupMockForSuccess('add', 'get');
$this->assertEqual($this->cache->add($this->def, $this->config), true);
$this->assertEqual($this->cache->get($this->config), $this->def);
}
function test_add_failure() {
$this->setupMockForFailure('add', 'get');
$this->assertEqual($this->cache->add($this->def, $this->config), false);
$this->cache->get($this->config);
}
}

View File

@@ -4,7 +4,7 @@ generate_mock_once('HTMLPurifier_DefinitionCache');
class HTMLPurifier_DefinitionCache_DecoratorHarness extends HTMLPurifier_DefinitionCacheHarness
{
function setup() {
$this->mock = new HTMLPurifier_DefinitionCacheMock();
$this->mock->type = 'Test';
@@ -12,11 +12,11 @@ class HTMLPurifier_DefinitionCache_DecoratorHarness extends HTMLPurifier_Definit
$this->def = $this->generateDefinition();
$this->config = $this->generateConfigMock();
}
function teardown() {
unset($this->mock);
unset($this->cache);
}
}

View File

@@ -2,40 +2,40 @@
class HTMLPurifier_DefinitionCache_DecoratorTest extends HTMLPurifier_DefinitionCacheHarness
{
function test() {
generate_mock_once('HTMLPurifier_DefinitionCache');
$mock = new HTMLPurifier_DefinitionCacheMock();
$mock->type = 'Test';
$cache = new HTMLPurifier_DefinitionCache_Decorator();
$cache = $cache->decorate($mock);
$this->assertIdentical($cache->type, $mock->type);
$def = $this->generateDefinition();
$config = $this->generateConfigMock();
$mock->expectOnce('add', array($def, $config));
$cache->add($def, $config);
$mock->expectOnce('set', array($def, $config));
$cache->set($def, $config);
$mock->expectOnce('replace', array($def, $config));
$cache->replace($def, $config);
$mock->expectOnce('get', array($config));
$cache->get($config);
$mock->expectOnce('flush', array($config));
$cache->flush($config);
$mock->expectOnce('cleanup', array($config));
$cache->cleanup($config);
}
}

View File

@@ -2,164 +2,164 @@
class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_DefinitionCacheHarness
{
function test() {
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config = $this->generateConfigMock('serial');
$config->setReturnValue('get', 2, array('Test', 'DefinitionRev'));
$config->version = '1.0.0';
$config_md5 = '1.0.0,serial,2';
$file = realpath(
$rel_file = HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer/Test/' .
$config_md5 . '.ser'
);
if($file && file_exists($file)) unlink($file); // prevent previous failures from causing problems
$this->assertIdentical($config_md5, $cache->generateKey($config));
$def_original = $this->generateDefinition();
$cache->add($def_original, $config);
$this->assertFileExist($rel_file);
$file_generated = $cache->generateFilePath($config);
$this->assertIdentical(realpath($rel_file), realpath($file_generated));
$def_1 = $cache->get($config);
$this->assertIdentical($def_original, $def_1);
$def_original->info_random = 'changed';
$cache->set($def_original, $config);
$def_2 = $cache->get($config);
$this->assertIdentical($def_original, $def_2);
$this->assertNotEqual ($def_original, $def_1);
$def_original->info_random = 'did it change?';
$this->assertFalse($cache->add($def_original, $config));
$def_3 = $cache->get($config);
$this->assertNotEqual ($def_original, $def_3); // did not change!
$this->assertIdentical($def_3, $def_2);
$cache->replace($def_original, $config);
$def_4 = $cache->get($config);
$this->assertIdentical($def_original, $def_4);
$cache->remove($config);
$this->assertFileNotExist($file);
$this->assertFalse($cache->replace($def_original, $config));
$def_5 = $cache->get($config);
$this->assertFalse($def_5);
}
function test_errors() {
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$def = $this->generateDefinition();
$def->setup = true;
$def->type = 'NotTest';
$config = $this->generateConfigMock('testfoo');
$this->expectError('Cannot use definition of type NotTest in cache for Test');
$cache->add($def, $config);
$this->expectError('Cannot use definition of type NotTest in cache for Test');
$cache->set($def, $config);
$this->expectError('Cannot use definition of type NotTest in cache for Test');
$cache->replace($def, $config);
}
function test_flush() {
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config1 = $this->generateConfigMock('test1');
$config2 = $this->generateConfigMock('test2');
$config3 = $this->generateConfigMock('test3');
$def1 = $this->generateDefinition(array('info_candles' => 1));
$def2 = $this->generateDefinition(array('info_candles' => 2));
$def3 = $this->generateDefinition(array('info_candles' => 3));
$cache->add($def1, $config1);
$cache->add($def2, $config2);
$cache->add($def3, $config3);
$this->assertEqual($def1, $cache->get($config1));
$this->assertEqual($def2, $cache->get($config2));
$this->assertEqual($def3, $cache->get($config3));
$cache->flush($config1); // only essential directive is %Cache.SerializerPath
$this->assertFalse($cache->get($config1));
$this->assertFalse($cache->get($config2));
$this->assertFalse($cache->get($config3));
}
function testCleanup() {
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
// in order of age, oldest first
// note that configurations are all identical, but version/revision
// are different
$config1 = $this->generateConfigMock();
$config1->version = '0.9.0';
$config1->setReturnValue('get', 574, array('Test', 'DefinitionRev'));
$def1 = $this->generateDefinition(array('info' => 1));
$config2 = $this->generateConfigMock();
$config2->version = '1.0.0beta';
$config2->setReturnValue('get', 1, array('Test', 'DefinitionRev'));
$def2 = $this->generateDefinition(array('info' => 3));
$cache->set($def1, $config1);
$cache->cleanup($config1);
$this->assertEqual($def1, $cache->get($config1)); // no change
$cache->cleanup($config2);
$this->assertFalse($cache->get($config1));
$this->assertFalse($cache->get($config2));
}
function testCleanupOnlySameID() {
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config1 = $this->generateConfigMock('serial1');
$config1->version = '1.0.0';
$config1->setReturnValue('get', 1, array('Test', 'DefinitionRev'));
$def1 = $this->generateDefinition(array('info' => 1));
$config2 = $this->generateConfigMock('serial2');
$config2->version = '1.0.0';
$config2->setReturnValue('get', 34, array('Test', 'DefinitionRev'));
$def2 = $this->generateDefinition(array('info' => 3));
$cache->set($def1, $config1);
$cache->cleanup($config1);
$this->assertEqual($def1, $cache->get($config1)); // no change
$cache->set($def2, $config2);
$cache->cleanup($config2);
$this->assertEqual($def1, $cache->get($config1));
$this->assertEqual($def2, $cache->get($config2));
$cache->flush($config1);
}
/**
* Asserts that a file exists, ignoring the stat cache
*/
@@ -167,31 +167,31 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
clearstatcache();
$this->assertTrue(file_exists($file), 'Expected ' . $file . ' exists');
}
/**
* Asserts that a file does not exist, ignoring the stat cache
*/
function assertFileNotExist($file) {
$this->assertFalse(file_exists($file), 'Expected ' . $file . ' does not exist');
}
function testAlternatePath() {
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config = $this->generateConfigMock('serial');
$config->version = '1.0.0';
$config->setReturnValue('get', 1, array('Test', 'DefinitionRev'));
$dir = dirname(__FILE__) . '/SerializerTest';
$config->setReturnValue('get', $dir, array('Cache', 'SerializerPath'));
$def_original = $this->generateDefinition();
$cache->add($def_original, $config);
$this->assertFileExist($dir . '/Test/1.0.0,serial,1.ser');
unlink($dir . '/Test/1.0.0,serial,1.ser');
rmdir( $dir . '/Test');
}
}