It's entirely possible that I've missed something, but given a situation where an application is taking advantage of the Bootstrap--and associated resource container--being assigned as a parameter on the front controller, won't the current dispatch() method for the ControllerTestCase cause issues trying to test controllers?
Example:
application/controllers/IndexController.php
---------------------------------------------
class IndexController extends Zend_Controller_Action
{
//...
public function indexAction() {
$someResource = $this->getInvokeArg('bootstrap')->getContainer()->resource;
//...
}
tests/application/controllers/IndexControllerTest.php
----------------------------------------------
class IndexControllerTest extends ControllerTestCase
{
//...
public function testIndexActionDisplayesResource() {
$this->dispatch('/');
$this->assertAction('index');
}
}
Where ControllerTestCase is an extension of Zend_Test_PHPUnit_ControllerTestCase that creates a Zend_Application object and sets the bootstrap to call $this->_application->bootstrap().
However, the test will cause a fatal error because the bootstrap param does not exist in the front controller and thus is not passed to the IndexController. However, overriding the ControllerTestCase method dispatch() and adding the bootstrap param manually works--obviously.
So did I miss something, or is this the best way for now?
Thanks,
- Jeff
没有评论:
发表评论