class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
var_dump($this->getInvokeArg('bootstrap')); // It should NOT output NULL, but an instance of class "Zend_Application_Bootstrap_Bootstrap" under the unit testing environment
}
}
class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public $application;
public function setUp()
{
$this->application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$this->bootstrap = array($this, 'appBootstrap');
parent::setUp();
}
public function appBootstrap()
{
$this->application->bootstrap();
}
public function testIndexAction() {
$this->dispatch('/');
$this->assertType('Zend_Application_Bootstrap_Bootstrap', $this->_frontController->getParam('bootstrap')); // FAILURE
}
}
Comments
Posted by Brian Reich (breich) on 2009-12-15T07:48:08.000+0000
I've worked around this issue by applying the following patch to my Bootstrap:
<?php/** * This file contains the Bootstrap class, which bootstraps resources for the * SUN Tech Web Services application. * * SUN Tech Web Services * PHP 5.2.9, Zend Framework 1.7.5, ExtJS 2.0 * * @author Brian Reich breich@sun-tech.org * @copyright 2008 (C) SUN Area Technical Institute * @category Public * @package Public * @version 2.0 */
/** * Bootstrap extends Zend_Application_Bootstrap_Bootstrap. */ require_once 'Zend/Application/Bootstrap/Bootstrap.php';
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { // ...
}
Posted by Matthew Turland (elazar) on 2009-12-29T10:55:54.000+0000
The issue is that Zend_Test_PHPUnit_ControllerTestCase doesn't call Zend_Application::run() anywhere. That method is responsible for calling Zend_Application_Bootstrap_Bootstrap::run(), which in turn calls Zend_Controller_Front::setParam() to store a reference to the bootstrap in the front controller as an invoking parameter. I believe Zend_Test_PHPUnit_ControllerTestCase should be modified, likely either in its bootstrap() method or its dispatch() method, to handle this.
Posted by Matthew Weier O'Phinney (matthew) on 2010-01-13T08:19:05.000+0000
Resolved in trunk with r20256.
Posted by miholeus (miholeus) on 2010-10-28T00:37:54.000+0000
Not resolved in last release versions
Posted by Matthew Weier O'Phinney (matthew) on 2010-10-28T05:38:35.000+0000
Actually, it is. Based on what you reported in ZF-10607, you were setting up your testing bootstrap incorrectly.
Posted by Enrico Zimuel (zimuel) on 2011-04-07T16:04:16.000+0000
I'm checking with ZF 1.11.3 and seems that the issue is still present. Here my code of testing:
and the following testCase:
That fails.
Posted by Bart McLeod (mcleod@spaceweb.nl) on 2011-05-08T21:20:30.000+0000
This issue seems to be triggered by this blog post (possibly among others): http://ailoo.net/2009/04/…
I commented on that post hoping that Matthias will adjust the example.
A correct setup for your tests looks like this:
This is taken from Matthew's example in the related issue.
Posted by Bart McLeod (mcleod@spaceweb.nl) on 2011-05-08T21:21:28.000+0000
This is no issue, so I close it.