DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Running the unit tests on the command line in TYPO3 8.7

  1. Make sure that there is at least one front-end page in your TYPO3 installation.
  2. Execute <path-to-your-typo3-installation>/typo3/sysext/core/bin/typo3 phpunit:run <path-to-your-tests>

Running the unit tests on the command line in TYPO3 7.6

  1. Create a non-admin back-end user named “_cli_phpunit”. This is the user which then will be used to run the tests.
  2. Make sure that there is at least one front-end page in your TYPO3 installation.
  3. Make sure that your testcase files end with “*Test.php”, not with “*_testcase.php”.
  4. Execute <path-to-your-typo3-installation>/typo3/cli_dispatch.phpsh phpunit <path-to-your-tests>

As the CLI BE user must not have administrator privileges, you might need to write your unit tests to accommodate to that. This might include the following things:

  • If you need a logged-in BE user with certain data or with administrator privileges: create a mock BE user in $GLOBALS['BE_USER']

Running the tests on the command line on MAMP/XAMPP etc.

If you are using MAMP , you need to edit your localconf.php. (The problem is that MAMP uses another mysql socket than the default socket.) To fix this, edit your localconf.php and add the socket behind the typo3_db host, e.g.:

$typo_db_host = 'localhost:/Applications/MAMP/tmp/mysql/mysql.sock';

Applications like Xampp/Mamp on (Mac os X) provide their own PHP binary which is needed to execute the CLi dispatcher. Example:

Won't work:

$ ./typo3/cli_dispatch.phpsh phpunit typo3conf/ext/coffee/Tests/

Works:

$ /Applications/XAMPP/xamppfiles/bin/php-5.3.1 ./typo3/cli_dispatch.phpsh phpunit typo3conf/ext/coffee/Tests/