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->assertSame($resource->getCache(), $this->bootstrap->cacheManager); } 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(); }