Skip to content
Browse files

XCache options and tests

  • Loading branch information...
1 parent 476534d commit e0ecfca0b260623101346bef61c7307e6eff3684 @marc-mabe committed Sep 14, 2012
View
2 library/Zend/Cache/Storage/Adapter/XCache.php
@@ -175,7 +175,7 @@ protected function internalGetItem(& $normalizedKey, & $success = null, & $casTo
$success = ($result !== null);
if ($success) {
- $casToken = $value;
+ $casToken = $result;
}
return $result;
View
2 library/Zend/Cache/Storage/Adapter/XCacheOptions.php
@@ -96,7 +96,7 @@ public function getAdminUser()
* @param null|string $adminPass
* @return XCacheOptions
*/
- public function setAdminUser($adminPass)
+ public function setAdminPass($adminPass)
{
$adminPass = ($adminPass === null) ? null : (string)$adminPass;
if ($this->adminPass !== $adminPass) {
View
75 tests/ZendTest/Cache/Storage/Adapter/XCacheTest.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Cache
+ */
+
+namespace ZendTest\Cache\Storage\Adapter;
+
+use Zend\Cache;
+
+/**
+ * @category Zend
+ * @package Zend_Cache
+ * @subpackage UnitTests
+ * @group Zend_Cache
+ */
+class XCacheTest extends CommonAdapterTest
+{
+
+ public function setUp()
+ {
+ if (!defined('TESTS_ZEND_CACHE_XCACHE_ENABLED') || !TESTS_ZEND_CACHE_XCACHE_ENABLED) {
+ //$this->markTestSkipped("Skipped by TestConfiguration (TESTS_ZEND_CACHE_XCACHE_ENABLED)");
+ }
+
+ if (!extension_loaded('xcache')) {
+ try {
+ new Cache\Storage\Adapter\XCache();
+ $this->fail("Expected exception Zend\Cache\Exception\ExtensionNotLoadedException");
+ } catch (Cache\Exception\ExtensionNotLoadedException $e) {
+ $this->markTestSkipped($e->getMessage());
+ }
+ }
+
+ if (PHP_SAPI == 'cli') {
+ try {
+ new Cache\Storage\Adapter\XCache();
+ $this->fail("Expected exception Zend\Cache\Exception\ExtensionNotLoadedException");
+ } catch (Cache\Exception\ExtensionNotLoadedException $e) {
+ $this->markTestSkipped($e->getMessage());
+ }
+ }
+
+ if ((int)ini_get('xcache.var_size') <= 0) {
+ try {
+ new Cache\Storage\Adapter\XCache();
+ $this->fail("Expected exception Zend\Cache\Exception\ExtensionNotLoadedException");
+ } catch (Cache\Exception\ExtensionNotLoadedException $e) {
+ $this->markTestSkipped($e->getMessage());
+ }
+ }
+
+ $this->_options = new Cache\Storage\Adapter\XCacheOptions();
+ $this->_storage = new Cache\Storage\Adapter\XCache();
+ $this->_storage->setOptions($this->_options);
+
+ parent::setUp();
+ }
+
+ public function tearDown()
+ {
+ if (function_exists('xcache_clear_cache')) {
+ $cnt = xcache_count(XC_TYPE_VAR);
+ for ($i=0; $i < $cnt; $i++) {
+ xcache_clear_cache(XC_TYPE_VAR, $i);
+ }
+ }
+
+ parent::tearDown();
+ }
+}

0 comments on commit e0ecfca

Please sign in to comment.
Something went wrong with that request. Please try again.