Skip to content
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

Merged
merged 7 commits into from
Sep 21, 2020

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Jul 24, 2020

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 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.

PHPUnit: use a type-safe assertion

assertEquals() is to assertSame() as == is to ===, so always use assertSame() 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 the Highlighter class uses PHP_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() 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.

Ant: fail the build on unit test failures

Travis: allow for installing PHPUnit on PHP 8

jrfnl added 7 commits August 13, 2020 16:42
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`.
@jrfnl jrfnl force-pushed the feature/update-test-suite branch from 03f65d6 to bbdcaf8 Compare August 13, 2020 14:43
@jrfnl
Copy link
Collaborator Author

jrfnl commented Aug 13, 2020

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 --ignore-platform-reqs is no longer needed to install PHPUnit on PHP 8.

@jrfnl
Copy link
Collaborator Author

jrfnl commented Aug 13, 2020

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).

@grogy grogy merged commit 86cdfc3 into php-parallel-lint:master Sep 21, 2020
@grogy
Copy link
Member

grogy commented Sep 21, 2020

Thank you :-)

@grogy
Copy link
Member

grogy commented Sep 21, 2020

I added parts from this PR to changelog. Your PR did more great maintenance work, thank you 👍

@jrfnl jrfnl deleted the feature/update-test-suite branch September 21, 2020 19:25
@jrfnl jrfnl added this to the 1.0.0 milestone Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants