소스 검색

ZF-4697: fix plugin loader classpath matching

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21152 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 년 전
부모
커밋
e752017b92
3개의 변경된 파일24개의 추가작업 그리고 3개의 파일을 삭제
  1. 0 2
      library/Zend/Loader/PluginLoader.php
  2. 24 0
      tests/Zend/Loader/PluginLoaderTest.php
  3. 0 1
      tests/Zend/ViewTest.php

+ 0 - 2
library/Zend/Loader/PluginLoader.php

@@ -408,10 +408,8 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface
 
         if ($this->_useStaticRegistry) {
             self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]     = $className;
-            self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = (isset($loadFile) ? $loadFile : '');
         } else {
             $this->_loadedPlugins[$name]     = $className;
-            $this->_loadedPluginPaths[$name] = (isset($loadFile) ? $loadFile : '');
         }
         return $className;
     }

+ 24 - 0
tests/Zend/Loader/PluginLoaderTest.php

@@ -455,6 +455,30 @@ class Zend_Loader_PluginLoaderTest extends PHPUnit_Framework_TestCase
             "Zend_View_Helper_" => array("Zend/View/Helper/"),
         ), $loader2->getPaths());
     }
+
+    /**
+     * @group ZF-4697
+     */
+    public function testClassFilesGrabCorrectPathForLoadedClasses()
+    {
+        require_once 'Zend/View/Helper/DeclareVars.php';
+        $reflection = new ReflectionClass('Zend_View_Helper_DeclareVars');
+        $expected   = $reflection->getFileName();
+        
+        $loader = new Zend_Loader_PluginLoader(array());
+        $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper');
+        $loader->addPrefixPath('ZfTest', dirname(__FILE__) . '/_files/ZfTest');
+        try {
+            // Class in /Zend/View/Helper and not in /_files/ZfTest
+            $className = $loader->load('DeclareVars');
+        } catch (Exception $e) {
+            $paths = $loader->getPaths();
+            $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
+        }
+        
+        $classPath = $loader->getClassPath('DeclareVars');
+        $this->assertContains($expected, $classPath);
+    }
 }
 
 // Call Zend_Loader_PluginLoaderTest::main() if this source file is executed directly.

+ 0 - 1
tests/Zend/ViewTest.php

@@ -662,7 +662,6 @@ class Zend_ViewTest extends PHPUnit_Framework_TestCase
         ob_start();
         echo $view->render('testZf995.phtml');
         $content = ob_get_flush();
-        ob_end_clean();
         $this->assertTrue(empty($content));
     }