2010年8月20日星期五

Re: [fw-mvc] Re: Call to a member function hasPluginResource() on a non-object (phpunit)

I ran into a similar problem and was able to solve it by manually adding the bootstrap to the front controller:

Zend_Controller_Front::getInstance()->setParam('bootstrap', $this->bootstrap);

For some reason this isn't done automatically for unit tests.

On Aug 20, 2010 9:18 AM, "greg606" <greg606@gmail.com> wrote:


I have something similar, but still it doesn't work:

<?php
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';

abstract class ControllerTestCase 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 tearDown() {
               Zend_Controller_Front::getInstance ()->resetInstance ();
               $this->resetRequest ();
               $this->resetResponse ();
               $this->request
                       ->setPost ( array () );
               $this->request
                       ->setQuery ( array () );
       }

}
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Call-to-a-member-function-hasPluginResource-on-a-non-object-phpunit-tp2327025p2332713.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: