From 4cf05205d4c10200e978040ea4df350ab1a9e857 Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Tue, 29 Oct 2013 00:18:22 +0200 Subject: [PATCH 1/3] added cache mset() base test --- tests/unit/framework/caching/CacheTestCase.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/framework/caching/CacheTestCase.php b/tests/unit/framework/caching/CacheTestCase.php index 9ff6409..fc84cf1 100644 --- a/tests/unit/framework/caching/CacheTestCase.php +++ b/tests/unit/framework/caching/CacheTestCase.php @@ -92,6 +92,25 @@ abstract class CacheTestCase extends TestCase $this->assertEquals('array_test', $array['array_test']); } + public function testMset() + { + $cache = $this->getCacheInstance(); + $cache->flush(); + + $this->assertTrue($cache->mset(['string_test' => 'string_test', + 'number_test' => 42, + 'array_test' => ['array_test' => 'array_test'], + ])); + + $this->assertEquals('string_test', $cache->get('string_test')); + + $this->assertEquals(42, $cache->get('number_test')); + + $array = $cache->get('array_test'); + $this->assertArrayHasKey('array_test', $array); + $this->assertEquals('array_test', $array['array_test']); + } + public function testExists() { $cache = $this->prepare(); From 8f8adb2a4868d5891e3f8fd31ac3d560d8014c20 Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Tue, 29 Oct 2013 00:43:26 +0200 Subject: [PATCH 2/3] added phpdoc block for mset() --- framework/yii/caching/Cache.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/framework/yii/caching/Cache.php b/framework/yii/caching/Cache.php index f9d117d..14f16c9 100644 --- a/framework/yii/caching/Cache.php +++ b/framework/yii/caching/Cache.php @@ -93,7 +93,7 @@ abstract class Cache extends Component implements \ArrayAccess * If the given key is a string containing alphanumeric characters only and no more than 32 characters, * then the key will be returned back prefixed with [[keyPrefix]]. Otherwise, a normalized key * is generated by serializing the given key, applying MD5 hashing, and prefixing with [[keyPrefix]]. - * + * * @param mixed $key the key to be normalized * @return string the generated cache key */ @@ -216,6 +216,21 @@ abstract class Cache extends Component implements \ArrayAccess } /** + * Stores multiple items in cache. Each item contains a value identified by a key. + * If the cache already contains such a key, the existing value and + * expiration time will be replaced with the new ones, respectively. + * + * @param array $items the items to be cached, as key-value pairs. Each key can be a simple string or + * a complex data structure consisting of factors representing the key. + * @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire. + * @return boolean whether the items are successfully stored into cache + */ + public function mset($items, $expire = 0) + { + return false; + } + + /** * Stores a value identified by a key into cache if the cache does not contain this key. * Nothing will be done if the cache already contains the key. * @param mixed $key a key identifying the value to be cached value. This can be a simple string or From 3ebbab028449b0a82683d318c0cf931050f7a40d Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Tue, 29 Oct 2013 00:49:31 +0200 Subject: [PATCH 3/3] marked mset() test incomplete --- tests/unit/framework/caching/CacheTestCase.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/framework/caching/CacheTestCase.php b/tests/unit/framework/caching/CacheTestCase.php index fc84cf1..bbb312d 100644 --- a/tests/unit/framework/caching/CacheTestCase.php +++ b/tests/unit/framework/caching/CacheTestCase.php @@ -94,6 +94,8 @@ abstract class CacheTestCase extends TestCase public function testMset() { + $this->markTestIncomplete('Work in progress'); + $cache = $this->getCacheInstance(); $cache->flush();