Creating unit tests for your extension

  • In order to create a unit test, you need to create a directory Tests/Unit/ in your extension directory and add some PHP files ending with *Test.php containing a class with functions that have the @test annotation.

  • If you need to store data for fixtures, create a sub directory Tests/Fixtures/ or Tests/Unit/Fixtures/.

  • Consult the PHPUnit documentation for information on writing tests, available functions etc.

Things that work, but that are deprecated

  • tests/ (lowercase) as the name for the tests directory (instead of Tests/ (with a capital first letter)

  • using _testcase.php as suffix for test case files (instead of the *Test.php suffix)

  • using test_* as prefix for test functions (instead of the @test annotation)