It is recommended to use the phpunit.xml.dist file name for the PHPUnit configuration file to allow individual developers to overload it with a phpunit.xml file.
To this end, I've:
Renamed the PHPUnit configuration file.
Adjusted the corresponding export-ignore in .gitattributes.
Added phpunit.xml to the .gitignore file so overload files from individual developers do not get committed.
Removed the CLI arguments from the command in the Travis script: these aren't necessary as PHPUnit will pick up on the config file automatically and use the directives set.
PHPUnit: use the namespaced testcase
Commit 71c87a2 fixed this for the CheckTest.php file, but the other test files also needed fixing.
PHPUnit: don't use __construct() / cross-version compat up to PHPUnit 7.x
The __construct() method in the PHPUnit TestCase class is used by that class itself.
Overloading it from a child class, while not problematic in PHPUnit 4.x, is problematic in later PHPUnit versions.
Better to use the setUpBeforeClass()or setUp() methods instead to set up fixtures.
With this change, the unit tests can now be run on PHPUnit 4 - 7.
PHPUnit: use annotations for fixtures / cross-version compat up to PHPUnit 9.x
As of PHPUnit 8.x, the method signature for the setUpBeforeClass(), setUp(), tearDown() and tearDownAfterClass() fixture methods has changed to require the void return type.
As the void return type isn't available until PHP 7.1, this cannot be implemented.
Anntations to the rescue.
By renaming the setUpBeforeClass() methods to another, descriptive name and using the @beforeClass annotation, the tests can be made cross-version compatible up to PHPUnit 9.x.
With this change, the unit tests can now be run on PHPUnit 4 - 9.
As PHPUnit has a caching feature build in as of PHPUnit 8, we need to add the .phpunit.result.cache file to .gitignore.
Thank you. Extended commit messages are great, for example, information about usages annotation for old PHP. It is excellent preparation and I am glad for it
PHPUnit setup: rename the config file
It is recommended to use the
phpunit.xml.dist
file name for the PHPUnit configuration file to allow individual developers to overload it with aphpunit.xml
file.To this end, I've:
export-ignore
in.gitattributes
.phpunit.xml
to the.gitignore
file so overload files from individual developers do not get committed.PHPUnit: use the namespaced testcase
Commit 71c87a2 fixed this for the
CheckTest.php
file, but the other test files also needed fixing.PHPUnit: don't use __construct() / cross-version compat up to PHPUnit 7.x
The
__construct()
method in the PHPUnitTestCase
class is used by that class itself. Overloading it from a child class, while not problematic in PHPUnit 4.x, is problematic in later PHPUnit versions.Better to use the
setUpBeforeClass()
orsetUp()
methods instead to set up fixtures.With this change, the unit tests can now be run on PHPUnit 4 - 7.
PHPUnit: use annotations for fixtures / cross-version compat up to PHPUnit 9.x
As of PHPUnit 8.x, the method signature for the
setUpBeforeClass()
,setUp()
,tearDown()
andtearDownAfterClass()
fixture methods has changed to require thevoid
return type.As the
void
return type isn't available until PHP 7.1, this cannot be implemented.Anntations to the rescue. By renaming the
setUpBeforeClass()
methods to another, descriptive name and using the@beforeClass
annotation, the tests can be made cross-version compatible up to PHPUnit 9.x.With this change, the unit tests can now be run on PHPUnit 4 - 9.
As PHPUnit has a caching feature build in as of PHPUnit 8, we need to add the
.phpunit.result.cache
file to.gitignore
.