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); Zend_Controller_Action_HelperBroker::resetHelpers(); } 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); } // Reset autoloader instance so it doesn't affect other tests Zend_Loader_Autoloader::resetInstance(); } public function testInitializationInitializesViewObject() { require_once 'Zend/Application/Resource/View.php'; $resource = new Zend_Application_Resource_View(array()); $resource->init(); $this->assertTrue($resource->getView() instanceof Zend_View); } public function testInitializationInjectsViewIntoViewRenderer() { require_once 'Zend/Application/Resource/View.php'; $resource = new Zend_Application_Resource_View(array()); $resource->init(); $view = $resource->getView(); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $this->assertSame($view, $viewRenderer->view); } public function testOptionsPassedToResourceAreUsedToSetViewState() { $options = array( 'scriptPath' => dirname(__FILE__), ); require_once 'Zend/Application/Resource/View.php'; $resource = new Zend_Application_Resource_View($options); $resource->init(); $view = $resource->getView(); $paths = $view->getScriptPaths(); $this->assertContains(dirname(__FILE__) . '/', $paths, var_export($paths, 1)); } } if (PHPUnit_MAIN_METHOD == 'Zend_Application_Resource_ViewTest::main') { Zend_Application_Resource_ViewTest::main(); }