Просмотр исходного кода

ZF-6545: module bootstrap should call parent constructor

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15357 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 лет назад
Родитель
Сommit
bebcc328b2

+ 1 - 1
library/Zend/Application/Module/Bootstrap.php

@@ -51,7 +51,7 @@ abstract class Zend_Application_Module_Bootstrap
      */
     public function __construct($application)
     {
-        $this->setApplication($application);
+        parent::__construct($application);
 
         $key = strtolower($this->getModuleName());
         if ($application->hasOption($key)) {

+ 41 - 0
tests/Zend/Application/Module/BootstrapTest.php

@@ -63,6 +63,8 @@ class Zend_Application_Module_BootstrapTest extends PHPUnit_Framework_TestCase
         $this->autoloader = Zend_Loader_Autoloader::getInstance();
 
         $this->application = new Zend_Application('testing');
+
+        Zend_Controller_Front::getInstance()->resetInstance();
     }
 
     public function tearDown()
@@ -120,6 +122,45 @@ class Zend_Application_Module_BootstrapTest extends PHPUnit_Framework_TestCase
         $bootstrap = new ZfModule_Bootstrap($this->application);
         $this->assertEquals('baz', $bootstrap->foo);
     }
+
+    /**
+     * @group ZF-6545
+     */
+    public function testFrontControllerPluginResourceShouldBeRegistered()
+    {
+        require_once dirname(__FILE__) . '/../_files/ZfModuleBootstrap.php';
+        $bootstrap = new ZfModule_Bootstrap($this->application);
+        $this->assertTrue($bootstrap->hasPluginResource('FrontController'));
+    }
+
+    /**
+     * @group ZF-6545
+     */
+    public function testFrontControllerStateRemainsSameIfNoOptionsPassedToModuleBootstrap()
+    {
+        require_once dirname(__FILE__) . '/../_files/ZfModuleBootstrap.php';
+        $this->application->setOptions(array(
+            'resources' => array(
+                'frontController' => array(
+                    'baseUrl'             => '/foo',
+                    'controllerDirectory' => dirname(__FILE__),
+                ),
+                'bootstrap' => array(
+                    'path'  => dirname(__FILE__) . '/../_files/ZfAppBootstrap.php',
+                    'class' => 'ZfAppBootstrap',
+                )
+            ),
+        ));
+        $appBootstrap = $this->application->getBootstrap();
+        $appBootstrap->bootstrap('FrontController');
+        $front = $appBootstrap->getResource('FrontController');
+        $bootstrap = new ZfModule_Bootstrap($appBootstrap);
+        $bootstrap->bootstrap('FrontController');
+        $test = $bootstrap->getResource('FrontController');
+        $this->assertSame($front, $test);
+        $this->assertEquals('/foo', $test->getBaseUrl());
+        $this->assertEquals(dirname(__FILE__), $test->getControllerDirectory('default'));
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Application_Module_BootstrapTest::main') {