Procházet zdrojové kódy

ZF-11548: ensure module bootstraps are returned in an ArrayObject

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24226 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew před 14 roky
rodič
revize
3ddd5f4304

+ 5 - 6
library/Zend/Application/Resource/Modules.php

@@ -103,13 +103,13 @@ class Zend_Application_Resource_Modules extends Zend_Application_Resource_Resour
                 // resource, don't re-execute.
                 continue;
             }
-            
+
             $bootstraps[$module] = $bootstrapClass;
         }
 
         return $this->_bootstraps = $this->bootstrapBootstraps($bootstraps);
     }
-    
+
     /*
      * Bootstraps the bootstraps found. Allows for easy extension.
      * @param array $bootstraps Array containing the bootstraps to instantiate
@@ -117,15 +117,14 @@ class Zend_Application_Resource_Modules extends Zend_Application_Resource_Resour
     protected function bootstrapBootstraps($bootstraps)
     {
         $bootstrap = $this->getBootstrap();
-        $out = array();
-        
+        $out = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
+
         foreach($bootstraps as $module => $bootstrapClass) {
             $moduleBootstrap = new $bootstrapClass($bootstrap);
             $moduleBootstrap->bootstrap();
-            $this->_bootstraps[$module] = $moduleBootstrap;
             $out[$module] = $moduleBootstrap;
         }
-        
+
         return $out;
     }
 

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

@@ -182,6 +182,23 @@ class Zend_Application_Resource_ModulesTest extends PHPUnit_Framework_TestCase
         $bootstraps = $resource->init();
         $this->assertEquals(3, count((array)$bootstraps));
     }
+
+    /**
+     * @group ZF-11548
+     */
+    public function testGetExecutedBootstrapsShouldReturnArrayObject()
+    {
+        require_once 'Zend/Application/Resource/Modules.php';
+
+        $this->bootstrap->registerPluginResource('Frontcontroller', array(
+            'moduleDirectory' => dirname(__FILE__) . '/../_files/modules',
+        ));
+        $resource = new Zend_Application_Resource_Modules(array());
+        $resource->setBootstrap($this->bootstrap);
+        $resource->init();
+        $bootstraps = $resource->getExecutedBootstraps();
+        $this->assertType('ArrayObject', $bootstraps);
+    }
 }
 
 require_once 'Zend/Application/Resource/Modules.php';