Setting up the testing environment
In this recipe, we will prepare a testing environment that can be used to run automated unit tests and functional tests. Unit tests in Yii are based on PHPUnit and functional tests are based on Selenium server. Additionally, you need Xdebug to generate code coverage reports.
Getting ready
Make sure that you have properly configured PHP to work in a command-line mode
Use the
yiicwebapptool to generate a fresh applicationConfigure the application to use clean URLs as described in Chapter 2, Router, Controller, and Views, in the Configuring URL rules recipe
How to do it...
We will start with PHPUnit.
To install it, we need to set up PEAR first. In most Linux environments, it is already set up, so you can skip this part if it already works.
To test if PEAR works, open console and type
pear. You should get the following output:
If you get the preceding output after running pear, then everything is OK. If not, then you need to install it by carrying out the following...