At work I needed to integrate some TYPO3 extension in our Jenkins Continous Integration setup that runs unit tests, builds API docs, checks coding standards etc.
The extension was written by someone else, so it did not use our self-made TYPO3 loading scripts for PHPUnit but the TYPO3 phpunit extension. You can't simply run
$ cd tests $ phpunit .
but have to use the TYPO3 CLI script it provides:
$ cd /path/to/typo3 $ ./typo3/cli_dispatch.phpsh phpunit -c typo3conf/ext/someext/tests/phpunit.xml $
Unfortunately, this was all of the output: Nothing. Time to start debugging!
At first I made sure that I see an error and not a normal program that just didn't output anything:
$ ./typo3/cli_dispatch.phpsh phpunit status; echo $? 1 $
$? in shell script is the variable containing the exit status of the last ended program. Here it is 1, which is non-zero and thus means: error.
The other change I made was adding the undocumented status argument - that should output some technical data for the phpunit TYPO3 CLI script. That did obviously not help in any way.
TYPO3 sets error reporting and display settings itself, and you should not simply try to add some hacks to the relevant files. There are just too many of them, it will mess up your installation and there is a simpler way: Adjust typo3conf/localconf.php by adding
$TYPO3_CONF_VARS['SYS']['displayErrors'] = 2;
This is the highest error display setting in TYPO3, and it gives us some more information:
$ ./typo3/cli_dispatch.phpsh phpunit; echo $? ERROR: No backend user named "_cli_phpunit" was found! 0
We do know the cause of the problem. Creating the backend user via the admin interface (no special settings/groups, it just has to exist) makes the status command work:
$ ./typo3/cli_dispatch.phpsh phpunit status; echo $? Status of TYPO3 CLI script: Username [uid]: _cli_phpunit  Database: bbag_relaunch2012 PATH_site: /home/christian.weiske/bm/ 0
Now that the script works, phpunit can be run again:
$ ./typo3/cli_dispatch.phpsh phpunit typo3conf/ext/someext/tests/; echo $? 1
Still an error that does not get displayed. This time we need to tell TYPO3 that we are developers and not just normal users by adding the following line to typo3conf/localconf.php:
$TYPO3_CONF_VARS['SYS']['devIPmask'] = '*';
The devIPmask should be as restrictive as possible, but since we're on the development system AND have no real IP (since we're on CLI), this setting is temporarily ok. And it helps:
$ ./typo3/cli_dispatch.phpsh phpunit typo3conf/ext/someext/tests/; echo $? Uncaught TYPO3 Exception Neither "typo3conf/ext/someext/tests/.php" nor "typo3conf/ext/some/ext/tests/.php" could be opened. thrown in file /path/to/typo3/typo3conf/ext/phpunit/PEAR/PHPUnit/Util/Skeleton/Test.php in line 100 0
Using the configuration file made it work then:
$ ./typo3/cli_dispatch.phpsh phpunit -c typo3conf/ext/someext/tests/phpunit.xml PHPUnit 3.6.11 by Sebastian Bergmann Configuration read from /path/to/typo3/typo3conf/ext/someext/tests/phpunit.xml ................................... Time: 41 seconds, Memory: 79.42Mb OK (52 tests, 274 assertions)
To debug TYPO3 CLI scripts, make sure your typo3conf/localconf.php contains
$TYPO3_CONF_VARS['SYS']['displayErrors'] = 2; $TYPO3_CONF_VARS['SYS']['devIPmask'] = '*';