开发者

Zend Application not fully bootstraped when testing with PHPUnit

Zend Framework 1.11.2

PHPUnit 3.5.10

PHP 5.3.1

NetBeans 6.9.1

  1. http://pastebin.com/L5bi9AgY
  2. I followed Lebensold's tutorial.

Testing works, even with things like

$this->dispatch('/');

$this->assertResponseCode(200);

, but as soon as I require a controller class (pastebin, #33) to instantiate it in the setUp() method, I get an error saying that PHPUnit didn't find the parent class (Zend_Controller_Action). So my guess is that I've somehow missed something in bootstrap, because I don't get all the classes loaded (?).

Also, when using the "@covers Class::method" annotation, I get the same type of error.

开发者_JAVA百科Any suggestions are welcomed. Thanks.


Try requiring the controller class from within your setup, e.g.

    class SearchControllerTest extends ControllerTestCase {

        public function setUp() {

            parent::setUp();

            require_once(APPLICATION_PATH . '/controllers/SearchController.php');

        }
    }

I remember having similar problem and it worked this way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜