How’s this done? Do I just prepare a $_POST/$_GET/$_FILES set and pass it to the controller? Or is there some more elegant way to test the Yii controllers?
How’s this done? Do I just prepare a $_POST / $_GET / $_FILES set
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 Modelapproach in MVC pattern. More information here.