Explorar el Código

Added tests for WinCache adapter

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23762 44c647ce-9c0f-0410-b52a-842ac1e357ba
ezimuel hace 15 años
padre
commit
5e64755f3a

+ 34 - 1
tests/Zend/Cache/AllTests.php

@@ -40,6 +40,7 @@ require_once 'Zend/Cache/SkipTests.php';
 require_once 'Zend/Cache/SqliteBackendTest.php';
 require_once 'Zend/Cache/SqliteBackendTest.php';
 require_once 'Zend/Cache/StaticBackendTest.php';
 require_once 'Zend/Cache/StaticBackendTest.php';
 require_once 'Zend/Cache/TwoLevelsBackendTest.php';
 require_once 'Zend/Cache/TwoLevelsBackendTest.php';
+require_once 'Zend/Cache/WinCacheBackendTest.php';
 require_once 'Zend/Cache/XcacheBackendTest.php';
 require_once 'Zend/Cache/XcacheBackendTest.php';
 require_once 'Zend/Cache/ZendPlatformBackendTest.php';
 require_once 'Zend/Cache/ZendPlatformBackendTest.php';
 require_once 'Zend/Cache/ZendServerDiskTest.php';
 require_once 'Zend/Cache/ZendServerDiskTest.php';
@@ -107,6 +108,22 @@ class Zend_Cache_AllTests
             $suite->addTestSuite('Zend_Cache_ApcBackendTest');
             $suite->addTestSuite('Zend_Cache_ApcBackendTest');
         }
         }
 
 
+    	/*
+         * Check if WinCache tests are enabled, and if extension is available.
+         */
+        if (!defined('TESTS_ZEND_CACHE_WINCACHE_ENABLED') ||
+            constant('TESTS_ZEND_CACHE_WINCACHE_ENABLED') === false) {
+            $skipTest = new Zend_Cache_WinCacheBackendTest_SkipTests();
+            $skipTest->message = 'Tests are not enabled in TestConfiguration.php';
+            $suite->addTest($skipTest);
+        } else if (!extension_loaded('wincache')) {
+            $skipTest = new Zend_Cache_WinCacheBackendTest_SkipTests();
+            $skipTest->message = "Extension 'wincache' is not loaded";
+            $suite->addTest($skipTest);
+        } else {
+            $suite->addTestSuite('Zend_Cache_WinCacheBackendTest');
+        }
+        
         /*
         /*
          * Check if Xcache tests are enabled, and if extension is available.
          * Check if Xcache tests are enabled, and if extension is available.
          */
          */
@@ -133,7 +150,7 @@ class Zend_Cache_AllTests
             $suite->addTest($skipTest);
             $suite->addTest($skipTest);
         } else if (!extension_loaded('memcache')) {
         } else if (!extension_loaded('memcache')) {
             $skipTest = new Zend_Cache_MemcachedBackendTest_SkipTests();
             $skipTest = new Zend_Cache_MemcachedBackendTest_SkipTests();
-            $skipTest->message = "Extension 'APC' is not loaded";
+            $skipTest->message = "Extension 'memcache' is not loaded";
             $suite->addTest($skipTest);
             $suite->addTest($skipTest);
         } else {
         } else {
             if (!defined('TESTS_ZEND_CACHE_MEMCACHED_HOST')) {
             if (!defined('TESTS_ZEND_CACHE_MEMCACHED_HOST')) {
@@ -222,6 +239,22 @@ class Zend_Cache_AllTests
             $suite->addTestSuite('Zend_Cache_ZendServerShMemTest');
             $suite->addTestSuite('Zend_Cache_ZendServerShMemTest');
         }
         }
 
 
+    	/*
+         * Check if WinCache tests are enabled, and if extension is available.
+         */
+        if (!defined('TESTS_ZEND_CACHE_WINCACHE_ENABLED') ||
+            constant('TESTS_ZEND_CACHE_WINCACHE_ENABLED') === false) {
+            $skipTest = new Zend_Cache_TwoLevelsBackendTest_SkipTests();
+            $skipTest->message = 'Tests are not enabled in TestConfiguration.php';
+            $suite->addTest($skipTest);
+        } else if (!extension_loaded('wincache')) {
+            $skipTest = new Zend_Cache_TwoLevelsBackendTest_SkipTests();
+            $skipTest->message = "Extension 'wincache' is not loaded";
+            $suite->addTest($skipTest);
+        } else {
+            $suite->addTestSuite('Zend_Cache_TwoLevelsBackendTest');
+        }
+        
         return $suite;
         return $suite;
     }
     }
 }
 }

+ 11 - 0
tests/Zend/Cache/SkipTests.php

@@ -72,6 +72,17 @@ class Zend_Cache_ApcBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTes
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @group      Zend_Cache
  * @group      Zend_Cache
  */
  */
+class Zend_Cache_WinCacheBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests
+{
+}
+/**
+ * @category   Zend
+ * @package    Zend_Cache
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @group      Zend_Cache
+ */
 class Zend_Cache_XcacheBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests
 class Zend_Cache_XcacheBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests
 {
 {
 }
 }

+ 167 - 0
tests/Zend/Cache/WinCacheBackendTest.php

@@ -0,0 +1,167 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cache
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+/**
+ * Zend_Cache
+ */
+require_once 'Zend/Cache.php';
+require_once 'Zend/Cache/Backend/WinCache.php';
+
+/**
+ * Common tests for backends
+ */
+require_once 'CommonExtendedBackendTest.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Cache
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @group      Zend_Cache
+ */
+class Zend_Cache_WinCacheBackendTest extends Zend_Cache_CommonExtendedBackendTest {
+
+    protected $_instance;
+
+    public function __construct($name = null, array $data = array(), $dataName = '')
+    {
+        parent::__construct('Zend_Cache_Backend_WinCache', $data, $dataName);
+    }
+
+    public function setUp($notag = true)
+    {
+        $this->_instance = new Zend_Cache_Backend_WinCache(array());
+        parent::setUp($notag);
+    }
+
+    public function tearDown()
+    {
+        parent::tearDown();
+        unset($this->_instance);
+    }
+
+    public function testConstructorCorrectCall()
+    {
+        $test = new Zend_Cache_Backend_WinCache();
+    }
+
+    public function testCleanModeOld() {
+        $this->_instance->setDirectives(array('logging' => false));
+        $this->_instance->clean('old');
+        // do nothing, just to see if an error occured
+        $this->_instance->setDirectives(array('logging' => true));
+    }
+
+    public function testCleanModeMatchingTags() {
+        $this->_instance->setDirectives(array('logging' => false));
+        $this->_instance->clean('matchingTag', array('tag1'));
+        // do nothing, just to see if an error occured
+        $this->_instance->setDirectives(array('logging' => true));
+    }
+
+    public function testCleanModeNotMatchingTags() {
+        $this->_instance->setDirectives(array('logging' => false));
+        $this->_instance->clean('notMatchingTag', array('tag1'));
+        // do nothing, just to see if an error occured
+        $this->_instance->setDirectives(array('logging' => true));
+    }
+
+    // Because of limitations of this backend...
+    public function testGetWithAnExpiredCacheId() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testCleanModeMatchingTags2() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testCleanModeNotMatchingTags2() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testCleanModeNotMatchingTags3() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetIdsMatchingTags() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetIdsMatchingTags2() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetIdsMatchingTags3() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetIdsMatchingTags4() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetIdsNotMatchingTags() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetIdsNotMatchingTags2() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetIdsNotMatchingTags3() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+    
+    public function testGetTags() {
+    	$this->markTestSkipped('This test skipped due to limitations in this adapter.');
+    }
+
+    public function testSaveCorrectCall()
+    {
+        $this->_instance->setDirectives(array('logging' => false));
+        parent::testSaveCorrectCall();
+        $this->_instance->setDirectives(array('logging' => true));
+    }
+
+    public function testSaveWithNullLifeTime()
+    {
+        $this->_instance->setDirectives(array('logging' => false));
+        parent::testSaveWithNullLifeTime();
+        $this->_instance->setDirectives(array('logging' => true));
+    }
+
+    public function testSaveWithSpecificLifeTime()
+    {
+
+        $this->_instance->setDirectives(array('logging' => false));
+        parent::testSaveWithSpecificLifeTime();
+        $this->_instance->setDirectives(array('logging' => true));
+    }
+
+    public function testGetMetadatas($notag = true)
+    {
+        parent::testGetMetadatas($notag);
+    }
+
+}
+
+