I have an already running project done with Yii. For the next development phase, i'd like to use a TDD methodolody. Now, I have been playing around a bit getting all the complicated stuff installed (PHP and Selenium RC, headaches!), and finally gottem up and working. When I create a SampleTest.php and run it from console phpunit SampleTest.php it works just fine.
Now the issue is that this sample test is in fact an example, it doesn't use any of the models defined in my project. I would like to create new instances of my models, populate them, etc. But how can I do that without including one by one all the models, controllers, etc?
I have in my hands "The definitive guide to Yii" which, under Test Environment Setup, it says that if i use yiic webapp to create the new app, then a whole list of files and directories will be created (here is a link to that part of the book). What if its my case? I already have the application generated? I'm kinda lost, any help is appreciated.
Thanks!
Just create your tests at your_application/protected/tests/ folder: - unit tests at unit/ folder - functional tests at functional/ folder
First try create unit tests by this manual - http://www.yiiframework.com/doc/guide/1.1/en/test.unit. It's quite easy.
All your models, components, etc will be included automatically by bootstrap script. You can read more about it here (look at Part 3) - http://www.yiiframework.com/doc/guide/1.1/en/test.overview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With