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.
精彩评论