Permalink
Browse files

Throw exception when selected serializer is not installed

  • Loading branch information...
1 parent bd3f005 commit 5d509e23c25e366b2efb48d2466faf54e203d4cc @wa0x6e wa0x6e committed Sep 18, 2013
@@ -143,11 +143,19 @@ protected function _setOptions() {
case 'igbinary':
if (Memcached::HAVE_IGBINARY) {
$serializer = self::$serializer['igbinary'];
+ } else {
+ throw new CacheException(
+ __d('cake_dev', 'Memcached extension is not compiled with igbinary support')
+ );
}
break;
case 'json':
if (Memcached::HAVE_JSON) {
$serializer = self::$serializer['json'];
+ } else {
+ throw new CacheException(
+ __d('cake_dev', 'Memcached extension is not compiled with json support')
+ );
}
break;
}
@@ -172,7 +172,7 @@ public function testPhpSerializerSetting() {
}
/**
- * testPhpSerializerSetting method
+ * testJsonSerializerSetting method
*
* @return void
*/
@@ -195,7 +195,7 @@ public function testJsonSerializerSetting() {
}
/**
- * testPhpSerializerSetting method
+ * testIgbinarySerializerSetting method
*
* @return void
*/
@@ -218,6 +218,56 @@ public function testIgbinarySerializerSetting() {
}
/**
+ * testJsonSerializerThrowException method
+ *
+ * @return void
+ */
+ public function testJsonSerializerThrowException() {
+ $this->skipIf(
+ Memcached::HAVE_JSON,
+ 'Memcached extension is compiled with json support'
+ );
+
+ $Memcached = new TestMemcachedEngine();
+ $settings = array(
+ 'engine' => 'Memcached',
+ 'servers' => array('127.0.0.1:11211'),
+ 'persistent' => false,
+ 'serializer' => 'json'
+ );
+
+ $this->setExpectedException(
+ 'CacheException', 'Memcached extension is not compiled with json support'
+ );
+ $Memcached->init($settings);
+ }
+
+/**
+ * testIgbinarySerializerThrowException method
+ *
+ * @return void
+ */
+ public function testIgbinarySerializerThrowException() {
+ $this->skipIf(
+ Memcached::HAVE_IGBINARY,
+ 'Memcached extension is compiled with igbinary support'
+ );
+
+ $Memcached = new TestMemcachedEngine();
+ $settings = array(
+ 'engine' => 'Memcached',
+ 'servers' => array('127.0.0.1:11211'),
+ 'persistent' => false,
+ 'serializer' => 'igbinary'
+ );
+
+ $this->setExpectedException(
+ 'CacheException', 'Memcached extension is not compiled with igbinary support'
+ );
+ $Memcached->init($settings);
+ }
+
+/**
* test using authentication without memcached installed with SASL support
* throw an exception
*

0 comments on commit 5d509e2

Please sign in to comment.