Details
-
Type:
Unit Tests: Problem
-
Status:
Closed
-
Priority:
Trivial
-
Resolution: Not an Issue
-
Affects Version/s: 1.9.5
-
Fix Version/s: 1.10.0
-
Component/s: Zend_Test_PHPUnit
-
Labels:None
-
Tags:
Description
IndexController.php
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 } }
IndexControllerTest.php
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 } }
I've worked around this issue by applying the following patch to my Bootstrap:
<code>
<?php
/**
*
*/
/**
*/
require_once 'Zend/Application/Bootstrap/Bootstrap.php';
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
// ...
/**
*/
protected function _initFrontController()
{
$front = Zend_Controller_Front::getInstance();
// ...
/*
ZF-8193*/
if($front->getParam('bootstrap') === null) { $front->setParam('bootstrap', $this); }
return $front;
}
}
</code>
- 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 { // ... /**- Initializes the Front Controller
- @return Zend_Controller_Front Returns the Front Controller
*/
protected function _initFrontController()
{
$front = Zend_Controller_Front::getInstance();
// ... /*- Fix for
- Zend_Controller_Action->getInvokeArg('bootstrap') doesn't work
- under the unit testing environment.
*/
if($front->getParam('bootstrap') === null)
{
$front->setParam('bootstrap', $this);
}
return $front; } } </code>ZF-8193