Page MenuHomeDevCentral

Migrate tests to PHPUnit 6/7
Open, Needs TriagePublic


PHPUnit classes are now in namespaces

The migration is generally a straightforward class replacement (they are now sorted in namespace):

$ find . -type f -name '*.php' | xargs -n 1 gsed -i 's@PHPUnitFrameworkTestCase@PHPUnit\\Framework\\TestCase@g';

Global state

But for the notifications center, we could need to check the global state:

Global State

Starting with PHPUnit 6, the global and super-global variables are no longer backed up before and restored after each test by default. In general, this functionality is not required for clean, modern, object-oriented PHP code. This functionality slows down the execution of the test suite and increases memory usage.

Simply use the --globals-backup commandline option or set backupGlobals="true" in your XML configuration file to enable the backup of global and super-global variables before each test and their restoring after each test.


Furthermore, the best practice to test exceptions has been shifted from @expectedException annotations to expectEception() method.


Event Timeline

dereckson created this task.Feb 17 2018, 12:50
dereckson moved this task from Backlog to Dev on the Technical debt board.Feb 22 2018, 01:45
dereckson renamed this task from Migrate tests to PHPUnit 6 to Migrate tests to PHPUnit 6/7.Mar 23 2018, 00:07