Permalink
Browse files

CRedisCache UnitTest to verify #2750

  • Loading branch information...
1 parent b5be73a commit 4c1da89e4fccd1bdabd45b55f7f2be8222e6dd81 @cebe cebe committed Aug 11, 2013
Showing with 39 additions and 0 deletions.
  1. +39 −0 tests/framework/caching/CRedisCacheTest.php
@@ -129,4 +129,43 @@ public function testFlush()
$this->assertTrue($cache->flush());
$this->assertFalse($cache->get('number_test'));
}
+
+ /**
+ * Store a value that is 2 times buffer size big
+ * https://github.com/yiisoft/yii/pull/2750
+ */
+ public function testLargeData()
+ {
+ $app=$this->getApplication();
+ $cache=$app->cache;
+
+ $data=str_repeat('XX',8192); // http://www.php.net/manual/en/function.fread.php
+ $key='bigdata1';
+
+ $this->assertFalse($cache->get($key));
+ $cache->set($key,$data);
+ $this->assertTrue($cache->get($key)===$data);
+
+ // try with multibyte string
+ $data=str_repeat('ЖЫ',8192); // http://www.php.net/manual/en/function.fread.php
+ $key='bigdata2';
+
+ $this->assertFalse($cache->get($key));
+ $cache->set($key,$data);
+ $this->assertTrue($cache->get($key)===$data);
+ }
+
+ public function testMultiByteGetAndSet()
+ {
+ $app=$this->getApplication();
+ $cache=$app->cache;
+
+ $data=array('abc'=>'ежик',2=>'def');
+ $key='data1';
+
+ $this->assertFalse($cache->get($key));
+ $cache->set($key,$data);
+ $this->assertTrue($cache->get($key)===$data);
+ }
+
}

0 comments on commit 4c1da89

Please sign in to comment.