MDL-37903 cache: implemented cacheable_object_array

This commit is contained in:
Sam Hemelryk
2013-03-01 10:09:06 +13:00
parent cce0d9a100
commit 01a3333723
2 changed files with 94 additions and 0 deletions
+17
View File
@@ -231,6 +231,23 @@ class cache_phpunit_tests extends advanced_testcase {
$this->assertEquals('red_ptc_wfc', $result->property1);
$this->assertEquals('blue_ptc_wfc', $result->property2);
// Test array of objects
$specobject = new cache_phpunit_dummy_object('red', 'blue');
$data = new cacheable_object_array(array(
clone($specobject),
clone($specobject),
clone($specobject))
);
$this->assertTrue($cache->set($key, $data));
$result = $cache->get($key);
$this->assertInstanceOf('cacheable_object_array', $result);
$this->assertCount(3, $data);
foreach ($result as $item) {
$this->assertInstanceOf('cache_phpunit_dummy_object', $item);
$this->assertEquals('red_ptc_wfc', $item->property1);
$this->assertEquals('blue_ptc_wfc', $item->property2);
}
// Test set many.
$cache->set_many(array('key1' => 'data1', 'key2' => 'data2'));
$this->assertEquals('data1', $cache->get('key1'));