开发者

Running multiple PHPUnit tests within a single file with Zend?

I'm trying to setup unit testing for a controller class in the Zend Framework.

I'd like to write multiple tests for the same controller, and keep them all in the same test class. But when I follow the directions on the home page, I get the following exception when the second test function runs:

Zend_Controller_Exception: No default module defined for this application

When I comment out the first test function, so only one test fu开发者_运维知识库nctions runs, the error goes away.

I've used PHPUnit with other frameworks and not had this problem. Does anyone know why this is happening only when I try running multiple test methods within the same class?

UPDATE:

Managed to fix the exception by following the bootstrapping method outlined here: http://kelmadics.blogspot.com/2011/07/setting-up-phpunit-in-zend-framework.html


It sounds like to me that you have modules enabled but don't have a /application/modules/default/ module. So you either need to create a module called default, or in your bootstrap somewhere add:

$front->setControllerDirectory(array(
     'default' => '/path/to/application/controllers',
));

For more clarity, post some of your application.ini, especially if there's anything about modules in there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜