FLOW3 comes with a lot of unit tests, but to run those is only possible with the FLOW3 test runners from the Testing package. This has various reasons:
- The code under test uses some constants defined by FLOW3 during it's bootstrap. Those are not defined when the tests are run standalone.
- The code under test as well as the tests themselves rely on a working autoloader, which is not the case for plain PHPUnit runs.
- Some of the tests do not properly mock their subject's dependencies and thus need the FLOW3 instance provided by out test runners to work. This is clearly a bug in the tests :)
Now that I am using NetBeans I was longing to use it's PHPUnit integration and did a little timebox work on the topic. The result is that one can now run the FLOW3 unit tests in NetBeans with a little preparation...
- Make sure to upgrade the Testing package to it's latest version (so it has the Bootstrap.php file).
- Edit your NetBeans project configuration to instruct it to use mentioned Bootstrap.php as, well, bootstrap for PHPUnit.
- Now comes the tricky part (due to the way NetBeans thinks tests should be organized):
- Create a folder (basically somewhere, I put it into my project root) that will contain all tests from NetBeans point of view.
- In that folder create symlinks to all Unit folders of the individual packages. One way to do this is a little shell script:
for i in `ls ../Packages/Framework/` ;
do ln -s ../Packages/Framework/$i/Tests/Unit $i ;
- Configure that folder as the tests folder for your NetBeans project.
If all is well you can now test a class file with Cmd-F6, run a test file with Shift-F6, switch between test and class file using Cmd-Shift-T and adore all the glory of pretty test results: