-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the test suite #15
Update the test suite #15
Conversation
The test file did not reflect the name of the class within it.
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. * Adjusted the references to the file in the Ant `build.xml` file. As for the config file itself: * Added a name for the testsuite as is required in later PHPUnit versions. * Changed the coverage `filter` directive to be more precise. * Minor other tweaks.
`assertEquals()` is to `assertSame()` as `==` is to `===`, so always use `assertSame()` unless you _need_ a loose comparison.
The tests would fail on non-*nix systems as the "expected output" contains hard-coded `\n` line endings, while the code in the `Highlighter` class uses `PHP_EOL`. This allows the tests to run (and pass) on non-*nix platforms.
Tested & found the unit tests working on PHPUnit 4.x - 7.x, so allow for those versions.
…PUnit 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 `setUp()` method to another, descriptive name and using the `@before` 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`.
03f65d6
to
bbdcaf8
Compare
I've removed the last commit (Travis) as PHPUnit 9.3 has been released last week which is the first PHPUnit version which officially supports PHP 8, so |
Also: the build failure on PHP 8 is unrelated to this PR and would be solved via php-parallel-lint/PHP-Var-Dump-Check#7 (and a new tagged release of the Var Dump Check tool). |
Thank you :-) |
I added parts from this PR to changelog. Your PR did more great maintenance work, thank you 👍 |
Commit Details
PHPUnit: fix file name
The test file did not reflect the name of the class within it.
PHPUnit setup: rename and update 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.build.xml
file.As for the config file itself:
filter
directive to be more precise.PHPUnit: use a type-safe assertion
assertEquals()
is toassertSame()
as==
is to===
, so always useassertSame()
unless you need a loose comparison.PHPUnit: make the tests platform independent
The tests would fail on non-*nix systems as the "expected output" contains hard-coded
\n
line endings, while the code in theHighlighter
class usesPHP_EOL
.This allows the tests to run (and pass) on non-*nix platforms.
PHPUnit: widen the version requirements
Tested & found the unit tests working on PHPUnit 4.x - 7.x, so allow for those versions.
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
setUp()
method to another, descriptive name and using the@before
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
.Ant: fail the build on unit test failures
Travis: allow for installing PHPUnit on PHP 8