Issues

ZF-10607: CLONE -Zend_Controller_Action->getInvokeArg('bootstrap') doesn't work under the unit testing environment

Issue Type: Bug Created: 2010-10-28T00:40:16.000+0000 Last Updated: 2010-11-27T04:13:09.000+0000 Status: Resolved Fix version(s): Reporter: miholeus (miholeus) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Test_PHPUnit

Related issues: - ZF-7373

Attachments:

Description

<pre class="highlight">
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
    }
}



<pre class="highlight">
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 Matthew Weier O'Phinney (matthew) on 2010-10-28T05:38:00.000+0000

You're doing it wrong.

Simply assign the Zend_Application instance to the $bootstrap property.

<pre class="highlight">
class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{

    public $application;

    public function setUp()
    {
        $this->bootstrap = new Zend_Application(
            APPLICATION_ENV,
            APPLICATION_PATH . '/configs/application.ini'
        );
        parent::setUp();
    }

    public function testIndexAction() {
        $this->dispatch('/');
        $this->assertType('Zend_Application_Bootstrap_Bootstrap', $this->frontController->getParam('bootstrap')); // SUCCESS
    }
}

The above works perfectly.

Posted by miholeus (miholeus) on 2010-10-28T06:24:30.000+0000

Thanks. I understand now

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts