Revert "MDL-41106 cache: several fixes for the session cache."

This reverts commit 17aed88ed4.
This reverts commit 4e9ccabd81.
This reverts commit a0933c542e.
This commit is contained in:
Damyon Wiese
2013-08-19 15:32:56 +08:00
parent 2febf20223
commit 01f44f262a
4 changed files with 154 additions and 361 deletions
+3 -90
View File
@@ -1126,9 +1126,9 @@ class cache_phpunit_tests extends advanced_testcase {
}
/**
* Test that multiple application loaders work ok.
* Test that multiple loaders work ok.
*/
public function test_multiple_application_loaders() {
public function test_multiple_loaders() {
$instance = cache_config_phpunittest::instance(true);
$instance->phpunit_add_file_store('phpunittest1');
$instance->phpunit_add_file_store('phpunittest2');
@@ -1173,93 +1173,6 @@ class cache_phpunit_tests extends advanced_testcase {
$this->assertFalse($result['a']);
$this->assertEquals('B', $result['b']);
$this->assertFalse($result['c']);
// Test non-recursive deletes.
$this->assertTrue($cache->set('test', 'test'));
$this->assertSame('test', $cache->get('test'));
$this->assertTrue($cache->delete('test', false));
// We should still have it on a deeper loader.
$this->assertSame('test', $cache->get('test'));
// Test non-recusive with many functions.
$this->assertSame(3, $cache->set_many(array(
'one' => 'one',
'two' => 'two',
'three' => 'three'
)));
$this->assertSame('one', $cache->get('one'));
$this->assertSame(array('two' => 'two', 'three' => 'three'), $cache->get_many(array('two', 'three')));
$this->assertSame(3, $cache->delete_many(array('one', 'two', 'three'), false));
$this->assertSame('one', $cache->get('one'));
$this->assertSame(array('two' => 'two', 'three' => 'three'), $cache->get_many(array('two', 'three')));
}
/**
* Test that multiple application loaders work ok.
*/
public function test_multiple_session_loaders() {
/* @var cache_config_phpunittest $instance */
$instance = cache_config_phpunittest::instance(true);
$instance->phpunit_add_session_store('phpunittest1');
$instance->phpunit_add_session_store('phpunittest2');
$instance->phpunit_add_definition('phpunit/multi_loader', array(
'mode' => cache_store::MODE_SESSION,
'component' => 'phpunit',
'area' => 'multi_loader'
));
$instance->phpunit_add_definition_mapping('phpunit/multi_loader', 'phpunittest1', 3);
$instance->phpunit_add_definition_mapping('phpunit/multi_loader', 'phpunittest2', 2);
$cache = cache::make('phpunit', 'multi_loader');
$this->assertInstanceOf('cache_session', $cache);
$this->assertFalse($cache->get('test'));
$this->assertTrue($cache->set('test', 'test'));
$this->assertEquals('test', $cache->get('test'));
$this->assertTrue($cache->delete('test'));
$this->assertFalse($cache->get('test'));
$this->assertTrue($cache->set('test', 'test'));
$this->assertTrue($cache->purge());
$this->assertFalse($cache->get('test'));
// Test the many commands.
$this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
$this->assertArrayHasKey('c', $result);
$this->assertEquals('A', $result['a']);
$this->assertEquals('B', $result['b']);
$this->assertEquals('C', $result['c']);
$this->assertEquals($result, $cache->get_many(array('a', 'b', 'c')));
$this->assertEquals(2, $cache->delete_many(array('a', 'c')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
$this->assertArrayHasKey('c', $result);
$this->assertFalse($result['a']);
$this->assertEquals('B', $result['b']);
$this->assertFalse($result['c']);
// Test non-recursive deletes.
$this->assertTrue($cache->set('test', 'test'));
$this->assertSame('test', $cache->get('test'));
$this->assertTrue($cache->delete('test', false));
// We should still have it on a deeper loader.
$this->assertSame('test', $cache->get('test'));
// Test non-recusive with many functions.
$this->assertSame(3, $cache->set_many(array(
'one' => 'one',
'two' => 'two',
'three' => 'three'
)));
$this->assertSame('one', $cache->get('one'));
$this->assertSame(array('two' => 'two', 'three' => 'three'), $cache->get_many(array('two', 'three')));
$this->assertSame(3, $cache->delete_many(array('one', 'two', 'three'), false));
$this->assertSame('one', $cache->get('one'));
$this->assertSame(array('two' => 'two', 'three' => 'three'), $cache->get_many(array('two', 'three')));
}
/**
@@ -1535,4 +1448,4 @@ class cache_phpunit_tests extends advanced_testcase {
$this->assertInstanceOf('cache_request', $cache);
$this->assertArrayHasKey('cache_is_searchable', $cache->phpunit_get_store_implements());
}
}
}