[eluser]CarloGl[/eluser]
Hi Zair,
I'm not using FooStack. I plug in PHPUnit directly.
The way I go about this is by providing an alternative entry point that uses the same bootstrapping sequence provided by core/CodeIgniter.php, but stops before routing kicks in.
This requires:
- extracting the variable definitions in the index page into a config/settings.php file
- providing a bootstrap.php file included in test classes
I also use a sub class of PHPUnit_Framework_TestCase ( CITestCaseExtension ) to provide some basic common functionality to the test classes, including some rudimentary functions to set up fixtures.
The test classes are organized in an application/tests directory that mirrors the controllers' so that by pointing the phpunit script to that directory all the tests wherein are run together.
We have:
index.php
application
|__ config
| |__ settings.php
|__ controllers
| |__ myController.php
|__ tests
|__ bootstrap.php
|__ CITestCaseExtension.php
|__ myControllerTest.php
In this case changing to application and running:
phpunit --include-path /application tests
phpunit automatically runs myControllerTest instantiating myController
I'm attaching sample files to clarify.