开发者

How to unit test controllers in Yii

How's this done? Do I just prepare a $_PO开发者_StackOverflow中文版ST/$_GET/$_FILES set and pass it to the controller? Or is there some more elegant way to test the Yii controllers?


Usually, unit testing is performed for models, helper, components, etc. So in other words, for something that implements application business logic. For test application controllers, a commonly used process is Functional Testing.

More information on performing such tests can be found in the Yii documentation.

In a nutshell, use some thing like Selenium, which opens some url in a web-browser and collects information after the test.

Another technique to test controllers described over here.

By the way, if it is difficult to have the logic implemented into your controller, look for the Fat Model approach in MVC pattern. More information here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜