瀏覽代碼

Minor improvement for Zend_Load_Autoloader processing. Fixes problem with Zend_Soap_Wsdl class loading. Closes [ZF-6607].

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15763 44c647ce-9c0f-0410-b52a-842ac1e357ba
alexander 16 年之前
父節點
當前提交
4df0d71c8d

+ 6 - 3
tests/Zend/Application/ApplicationTest.php

@@ -55,7 +55,7 @@ class Zend_Application_ApplicationTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -86,6 +86,9 @@ class Zend_Application_ApplicationTest extends PHPUnit_Framework_TestCase
         foreach ($this->iniOptions as $key) {
             ini_restore($key);
         }
+
+        // Reset autoloader instance so it doesn't affect other tests
+        Zend_Loader_Autoloader::resetInstance();
     }
 
     public function testConstructorSetsEnvironment()
@@ -284,14 +287,14 @@ class Zend_Application_ApplicationTest extends PHPUnit_Framework_TestCase
         $application = new Zend_Application('testing', dirname(__FILE__) . '/_files/appconfig.inc');
         $this->assertTrue($application->hasOption('foo'));
     }
-    
+
     public function testPassingArrayOptionsWithConfigKeyShouldLoadOptions()
     {
         $application = new Zend_Application('testing', array('bar' => 'baz', 'config' => dirname(__FILE__) . '/_files/appconfig.inc'));
         $this->assertTrue($application->hasOption('foo'));
         $this->assertTrue($application->hasOption('bar'));
     }
-    
+
     public function testPassingArrayOptionsWithConfigKeyShouldLoadOptionsAndOverride()
     {
         $application = new Zend_Application('testing', array('foo' => 'baz', 'config' => dirname(__FILE__) . '/_files/appconfig.inc'));

+ 4 - 1
tests/Zend/Application/Bootstrap/BootstrapAbstractTest.php

@@ -59,7 +59,7 @@ class Zend_Application_Bootstrap_BootstrapAbstractTest extends PHPUnit_Framework
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -82,6 +82,9 @@ class Zend_Application_Bootstrap_BootstrapAbstractTest extends PHPUnit_Framework
         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 handleError($errno, $errstr)

+ 4 - 1
tests/Zend/Application/Bootstrap/BootstrapTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Bootstrap_BootstrapTest extends PHPUnit_Framework_TestCas
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -81,6 +81,9 @@ class Zend_Application_Bootstrap_BootstrapTest extends PHPUnit_Framework_TestCas
         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 resetFrontController()

+ 4 - 1
tests/Zend/Application/Module/AutoloaderTest.php

@@ -67,7 +67,7 @@ class Zend_Application_Module_AutoloaderTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -101,6 +101,9 @@ class Zend_Application_Module_AutoloaderTest extends PHPUnit_Framework_TestCase
 
         // Retore original include_path
         set_include_path($this->includePath);
+
+        // Reset autoloader instance so it doesn't affect other tests
+        Zend_Loader_Autoloader::resetInstance();
     }
 
     public function testDbTableResourceTypeShouldBeLoadedByDefault()

+ 4 - 1
tests/Zend/Application/Module/BootstrapTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Module_BootstrapTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -78,6 +78,9 @@ class Zend_Application_Module_BootstrapTest extends PHPUnit_Framework_TestCase
         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 testConstructorShouldInitializeModuleResourceLoaderWithModulePrefix()

+ 4 - 1
tests/Zend/Application/Resource/DbTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Resource_DbTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -79,6 +79,9 @@ class Zend_Application_Resource_DbTest extends PHPUnit_Framework_TestCase
         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 testAdapterIsNullByDefault()

+ 4 - 1
tests/Zend/Application/Resource/FrontcontrollerTest.php

@@ -59,7 +59,7 @@ class Zend_Application_Resource_FrontcontrollerTest extends PHPUnit_Framework_Te
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -86,6 +86,9 @@ class Zend_Application_Resource_FrontcontrollerTest extends PHPUnit_Framework_Te
         }
 
         Zend_Controller_Front::getInstance()->resetInstance();
+
+        // Reset autoloader instance so it doesn't affect other tests
+        Zend_Loader_Autoloader::resetInstance();
     }
 
     public function testInitializationCreatesFrontControllerInstance()

+ 4 - 1
tests/Zend/Application/Resource/LayoutTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Resource_LayoutTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -80,6 +80,9 @@ class Zend_Application_Resource_LayoutTest extends PHPUnit_Framework_TestCase
         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 testInitializationInitializesLayoutObject()

+ 4 - 1
tests/Zend/Application/Resource/LocaleTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Resource_LocaleTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -80,6 +80,9 @@ class Zend_Application_Resource_LocaleTest extends PHPUnit_Framework_TestCase
         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 testInitializationInitializesLocaleObject()

+ 3 - 0
tests/Zend/Application/Resource/ModulesTest.php

@@ -82,6 +82,9 @@ class Zend_Application_Resource_ModulesTest extends PHPUnit_Framework_TestCase
         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 testInitializationTriggersNothingIfNoModulesRegistered()

+ 13 - 10
tests/Zend/Application/Resource/NavigationTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Resource_NavigationTest extends PHPUnit_Framework_TestCas
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -80,13 +80,16 @@ class Zend_Application_Resource_NavigationTest extends PHPUnit_Framework_TestCas
         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 testInitializationInitializesNavigationObject()
     {
 		$this->bootstrap->registerPluginResource('view');
         $resource = new Zend_Application_Resource_Navigation(array());
-        $resource->setBootstrap($this->bootstrap); 
+        $resource->setBootstrap($this->bootstrap);
         $resource->init();
         $this->assertTrue($resource->getContainer() instanceof Zend_Navigation_Container);
 		$this->bootstrap->unregisterPluginResource('view');
@@ -101,38 +104,38 @@ class Zend_Application_Resource_NavigationTest extends PHPUnit_Framework_TestCas
         $this->assertTrue($test instanceof Zend_Navigation);
 		$this->bootstrap->unregisterPluginResource('view');
     }
-    
+
     public function testContainerIsStoredInViewhelper()
     {
    		$options = array('pages'=> array(new Zend_Navigation_Page_Mvc(array(
 		    'action'     => 'index',
 		    'controller' => 'index'))));
-   		
+
     	$this->bootstrap->registerPluginResource('view');
         $resource = new Zend_Application_Resource_Navigation($options);
         $resource->setBootstrap($this->bootstrap)->init();
-                
+
         $view = $this->bootstrap->getPluginResource('view')->getView();
         $number = $view->getHelper('navigation')->navigation()->count();
-        
+
         $this->assertEquals($number,1);
 		$this->bootstrap->unregisterPluginResource('view');
     }
-        
+
     public function testContainerIsStoredInRegistry()
     {
    		$options = array('pages'=> array(new Zend_Navigation_Page_Mvc(array(
 		    'action'     => 'index',
 		    'controller' => 'index'))), 'storage' => array('registry' => true));
-   		
+
         $resource = new Zend_Application_Resource_Navigation($options);
         $resource->setBootstrap($this->bootstrap)->init();
-                
+
         $key = Zend_Application_Resource_Navigation::DEFAULT_REGISTRY_KEY;
 		$this->assertEquals(Zend_Registry::isRegistered($key),true);
 		$container = Zend_Registry::get($key);
         $number = $container->count();
-        
+
         $this->assertEquals($number,1);
 		$this->bootstrap->unregisterPluginResource('view');
     }

+ 4 - 1
tests/Zend/Application/Resource/ResourceAbstractTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Resource_ResourceAbstractTest extends PHPUnit_Framework_T
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -79,6 +79,9 @@ class Zend_Application_Resource_ResourceAbstractTest extends PHPUnit_Framework_T
         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 testBootstrapIsNullByDefault()

+ 4 - 1
tests/Zend/Application/Resource/RouterTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Resource_RouterTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -80,6 +80,9 @@ class Zend_Application_Resource_RouterTest extends PHPUnit_Framework_TestCase
         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 testInitializationInitializesRouterObject()

+ 3 - 0
tests/Zend/Application/Resource/TranslateTest.php

@@ -86,6 +86,9 @@ class Zend_Application_Resource_TranslateTest extends PHPUnit_Framework_TestCase
         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 testInitializationInitializesTranslateObject()

+ 4 - 1
tests/Zend/Application/Resource/ViewTest.php

@@ -54,7 +54,7 @@ class Zend_Application_Resource_ViewTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -81,6 +81,9 @@ class Zend_Application_Resource_ViewTest extends PHPUnit_Framework_TestCase
         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()

+ 4 - 1
tests/Zend/Loader/Autoloader/ResourceTest.php

@@ -67,7 +67,7 @@ class Zend_Loader_Autoloader_ResourceTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -101,6 +101,9 @@ class Zend_Loader_Autoloader_ResourceTest extends PHPUnit_Framework_TestCase
 
         // Retore original include_path
         set_include_path($this->includePath);
+
+        // Reset autoloader instance so it doesn't affect other tests
+        Zend_Loader_Autoloader::resetInstance();
     }
 
     /**

+ 4 - 1
tests/Zend/Loader/AutoloaderTest.php

@@ -59,7 +59,7 @@ class Zend_Loader_AutoloaderTest extends PHPUnit_Framework_TestCase
         // Store original autoloaders
         $this->loaders = spl_autoload_functions();
         if (!is_array($this->loaders)) {
-            // spl_autoload_functions does not return empty array when no 
+            // spl_autoload_functions does not return empty array when no
             // autoloaders registered...
             $this->loaders = array();
         }
@@ -88,6 +88,9 @@ class Zend_Loader_AutoloaderTest extends PHPUnit_Framework_TestCase
 
         // Retore original include_path
         set_include_path($this->includePath);
+
+        // Reset autoloader instance so it doesn't affect other tests
+        Zend_Loader_Autoloader::resetInstance();
     }
 
     public function testAutoloaderShouldBeSingleton()

+ 32 - 5
tests/Zend/LoaderTest.php

@@ -64,6 +64,17 @@ class Zend_LoaderTest extends PHPUnit_Framework_TestCase
 
     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();
+        }
+
+        // Store original include_path
+        $this->includePath = get_include_path();
+
         $this->error = null;
         $this->errorHandler = null;
         Zend_Loader_Autoloader::resetInstance();
@@ -74,6 +85,22 @@ class Zend_LoaderTest extends PHPUnit_Framework_TestCase
         if ($this->errorHandler !== null) {
             restore_error_handler();
         }
+
+        // Restore original autoloaders
+        $loaders = spl_autoload_functions();
+        foreach ($loaders as $loader) {
+            spl_autoload_unregister($loader);
+        }
+
+        foreach ($this->loaders as $loader) {
+            spl_autoload_register($loader);
+        }
+
+        // Retore original include_path
+        set_include_path($this->includePath);
+
+        // Reset autoloader instance so it doesn't affect other tests
+        Zend_Loader_Autoloader::resetInstance();
     }
 
     public function setErrorHandler()
@@ -427,15 +454,15 @@ class Zend_LoaderTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * In order to play nice with spl_autoload, an autoload callback should 
-     * *not* emit errors (exceptions are okay). ZF-2923 requests that this 
+     * In order to play nice with spl_autoload, an autoload callback should
+     * *not* emit errors (exceptions are okay). ZF-2923 requests that this
      * behavior be applied, which counters the previous request in ZF-2463.
      *
-     * As it is, the new behavior *will* hide parse and other errors. However, 
-     * a fatal error *will* be raised in such situations, which is as 
+     * As it is, the new behavior *will* hide parse and other errors. However,
+     * a fatal error *will* be raised in such situations, which is as
      * appropriate or more appropriate than raising an exception.
      *
-     * NOTE: Removed from test suite, as autoload functionality in Zend_Loader 
+     * NOTE: Removed from test suite, as autoload functionality in Zend_Loader
      * is now deprecated.
      *
      * @see    http://framework.zend.com/issues/browse/ZF-2463

二進制
tests/Zend/Paginator/_files/test.sqlite