Просмотр исходного кода

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20058 44c647ce-9c0f-0410-b52a-842ac1e357ba

freak 16 лет назад
Родитель
Сommit
2b4b47e0c9

+ 0 - 73
library/Zend/Application/Resource/Cache.php

@@ -1,73 +0,0 @@
-<?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_Application
- * @subpackage Resource
- * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * @version    $Id: $
- */
-
-require_once 'Zend/Application/Resource/ResourceAbstract.php';
-
-/**
- * Cache Manager resource
- *
- * @category   Zend
- * @package    Zend_Application
- * @subpackage Resource
- * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Application_Resource_Cache extends Zend_Application_Resource_ResourceAbstract
-{
-    /**
-     * @var Zend_Cache_Manager
-     */
-    protected $_manager = null;
-
-    /**
-     * Initialize Cache_Manager
-     *
-     * @return Zend_Cache_Manager
-     */
-    public function init()
-    {
-        return $this->getCacheManager();
-    }
-
-    /**
-     * Retrieve Cache Manager instance
-     *
-     * @return Zend_Cache_Manager
-     */
-    public function getCacheManager()
-    {
-        if (null === $this->_manager) {
-            $this->_manager = new Zend_Cache_Manager;
-
-            $options = $this->getOptions();
-            foreach ($options as $key => $value) {
-                if ($this->_manager->hasCacheTemplate($key)) {
-                    $this->_manager->setTemplateOptions($key, $value);
-                } else {
-                    $this->_manager->setCacheTemplate($key, $value);
-                }
-            }
-        }
-
-        return $this->_manager;
-    }
-}

+ 13 - 17
library/Zend/Application/Resource/Cachemanager.php

@@ -45,33 +45,29 @@ class Zend_Application_Resource_Cachemanager extends Zend_Application_Resource_R
      */
     public function init()
     {
-        $manager = $this->getCacheManager();
-
-        foreach ($this->getOptions() as $key => $value) {
-            if ($manager->hasCacheTemplate($key)) {
-                $manager->setTemplateOptions($key, $value);
-            } else {
-                $manager->setCacheTemplate($key, $value);
-            }
-        }
-
-        if (null !== ($bootstrap = $this->getBootstrap())) {
-            $this->getBootstrap()->cacheManager = $manager;
-        }
-
-        return $manager;
+        return $this->getCacheManager();
     }
 
     /**
-     * Retrieve front controller instance
+     * Retrieve Zend_Cache_Manager instance
      *
-     * @return Zend_Controller_Front
+     * @return Zend_Cache_Manager
      */
     public function getCacheManager()
     {
         if (null === $this->_manager) {
             $this->_manager = new Zend_Cache_Manager;
+            
+            $options = $this->getOptions();
+            foreach ($options as $key => $value) {
+                if ($this->_manager->hasCacheTemplate($key)) {
+                    $this->_manager->setTemplateOptions($key, $value);
+                } else {
+                    $this->_manager->setCacheTemplate($key, $value);
+                }
+            }
         }
+        
         return $this->_manager;
     }
 }

+ 0 - 8
tests/Zend/Application/Resource/CacheManagerTest.php

@@ -105,14 +105,6 @@ class Zend_Application_Resource_CacheManagerTest extends PHPUnit_Framework_TestC
         $this->assertTrue($resource->getCachemanager() instanceof Zend_Cache_Manager);
     }
 
-    public function testInitializationPushesCacheManagerToBootstrapWhenPresent()
-    {
-        $resource = new Zend_Application_Resource_Cachemanager(array());
-        $resource->setBootstrap($this->bootstrap);
-        $resource->init();
-        $this->assertSame($resource->getCachemanager(), $this->bootstrap->cacheManager);
-    }
-
     public function testShouldReturnCacheManagerWhenComplete()
     {
         $resource = new Zend_Application_Resource_Cachemanager(array());

+ 0 - 166
tests/Zend/Application/Resource/CacheTest.php

@@ -1,166 +0,0 @@
-<?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_Application
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * @version    $Id$
- */
-
-if (!defined('PHPUnit_MAIN_METHOD')) {
-    define('PHPUnit_MAIN_METHOD', 'Zend_Application_Resource_CacheManagerTest::main');
-}
-
-/**
- * Test helper
- */
-require_once dirname(__FILE__) . '/../../../TestHelper.php';
-
-/**
- * Zend_Loader_Autoloader
- */
-require_once 'Zend/Loader/Autoloader.php';
-
-/**
- * Zend_Controller_Front
- */
-require_once 'Zend/Controller/Front.php';
-
-/**
- * Zend_Application_Resource_Cachemanager
- */
-require_once 'Zend/Application/Resource/Cache.php';
-
-/**
- * @category   Zend
- * @package    Zend_Application
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * @group      Zend_Application
- */
-class Zend_Application_Resource_CacheTest extends PHPUnit_Framework_TestCase
-{
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite(__CLASS__);
-        $result = PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    public function setUp()
-    {
-        // Store original autoloaders
-        $this->loaders = spl_autoload_functions();
-        if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no
-            // autoloaders registered...
-            $this->loaders = array();
-        }
-
-        Zend_Loader_Autoloader::resetInstance();
-        $this->autoloader = Zend_Loader_Autoloader::getInstance();
-
-        $this->application = new Zend_Application('testing');
-
-        require_once dirname(__FILE__) . '/../_files/ZfAppBootstrap.php';
-        $this->bootstrap = new ZfAppBootstrap($this->application);
-    }
-
-    public function tearDown()
-    {
-        // Restore original autoloaders
-        $loaders = spl_autoload_functions();
-        foreach ($loaders as $loader) {
-            spl_autoload_unregister($loader);
-        }
-
-        foreach ($this->loaders as $loader) {
-            spl_autoload_register($loader);
-        }
-
-        Zend_Controller_Front::getInstance()->resetInstance();
-
-        // Reset autoloader instance so it doesn't affect other tests
-        Zend_Loader_Autoloader::resetInstance();
-    }
-
-    public function testInitializationCreatesCacheManagerInstance()
-    {
-
-        $resource = new Zend_Application_Resource_Cache(array());
-        $resource->init();
-        $this->assertTrue($resource->getCache() instanceof Zend_Cache_Manager);
-    }
-
-/*    public function testInitializationPushesCacheManagerToBootstrapWhenPresent()
-    {
-        $resource = new Zend_Application_Resource_Cache(array());
-        $resource->setBootstrap($this->bootstrap);
-        $resource->init();
-        $this->bootstrap->registerPluginResource('cache');
-        $this->bootstrap->bootstrap();
-        $this->assertSame($resource->getCache(), $this->bootstrap->getResource('cache'));
-    }*/
-
-    public function testShouldReturnCacheManagerWhenComplete()
-    {
-        $resource = new Zend_Application_Resource_Cache(array());
-        $manager = $resource->init();
-        $this->assertTrue($manager instanceof Zend_Cache_Manager);
-    }
-
-    public function testShouldMergeConfigsIfOptionsPassedForDefaultCacheTemplate()
-    {
-        $options = array(
-            'page' => array(
-                'backend' => array(
-                    'options' => array(
-                        'cache_dir' => '/foo'
-                    )
-                )
-            )
-        );
-
-        $resource = new Zend_Application_Resource_Cache($options);
-        $manager = $resource->init();
-        $cacheTemplate = $manager->getCacheTemplate('page');
-        $this->assertEquals('/foo', $cacheTemplate['backend']['options']['cache_dir']);
-
-    }
-    
-    public function testShouldCreateNewCacheTemplateIfConfigNotMatchesADefaultTemplate()
-    {
-        $options = array(
-            'foo' => array(
-                'backend' => array(
-                    'options' => array(
-                        'cache_dir' => '/foo'
-                    )
-                )
-            )
-        );
-
-        $resource = new Zend_Application_Resource_Cache($options);
-        $manager = $resource->init();
-        $cacheTemplate = $manager->getCacheTemplate('foo');
-        $this->assertSame($options['foo'], $cacheTemplate);
-    }
-    
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Application_Resource_CacheTest::main') {
-    Zend_Application_Resource_CacheTest::main();
-}