-
Notifications
You must be signed in to change notification settings - Fork 0
Phpunit testing
As of the time of this writing, we are using phpUnit version 3.5.3 - installed via the PEAR package manager. If you have not done so, please read the wiki page describing How to set up ZRECommerce.
You should familiarize yourself with phpUnit by reading the official phpUnit manual.
Would you risk life and limb by flying on a plane knowing it hasn't been tested to see if it will even fly? Would you risk bungee-jumping without testing to see if the bungee cord is in working condition? The obvious answer a sane person would give is "No".
Deploying code without testing each and every part is similar in many ways to 'deploying' an airplane without testing all the parts first. You'd simply be ASKING for trouble.
Instead of writing messy print_r and var_dump calls all over the place, why not use a unit test instead? It's a cleaner and much more tangible way of testing all the components of an application. It's also a great way to keep an application orderly and manageable.
So, whenever you start thinking about a new component or feature to add, remember to build unit test(s) for your code, too.
You will notice a /test/ directory that mirrors the rest of the web application's directory structure. Every controller and library class has a unit test in the expected directory, with the word 'Test' appended to the file name.
To run all tests, simply run the following command on the shell:
phpunit AllTests.php
That will run all tests, including the controller tests.
To run all controller tests, simply run the following command on the shell:
phpunit ControllerTests.php
This will only run unit tests on the controllers.
- Previous: Convert and output to JSON
- Up: ZRECommerce Tutorials