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 unit tests setup #9

Merged
merged 5 commits into from
Sep 21, 2020

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Jul 30, 2020

As can be seen in the build against nightly on the latest master, the unit tests fail to run on PHP 8 at this moment, which makes ensuring compatibility with the upcoming PHP 8.0 release hard.

This PR updates the PHPUnit setup to allow the tests to be compatible with a wider range of PHPUnit versions, which will then allow them to run on PHP 8.0, even though they would still use an unsupported PHPUnit version (official PHPUnit support for PHP 8 is expected in the upcoming 9.3 release).

It also sets up the unit tests to actually fail the build if they don't pass and implements some stricter testing.

If you examine the build logs on Travis for this PR, you will see that the tests will now actually run against PHP nightly and pass.

Commit Details

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.
  • Added an explicit backupGlobals setting as the default value has changed across PHPUnit versions.

PHPUnit: use a type-safe assertion

assertEquals() is to assertSame() as == is to ===, so always use assertSame() unless you need a loose comparison.

PHPUnit: widen the version requirements

Made the unit tests compatible with PHPUnit 4.x - 7.x.

Travis: allow for installing PHPUnit 7 on PHP 8

Ant: fail the build on unit test failures

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.
* Added an explicit `backupGlobals` setting as the default value has changed across PHPUnit versions.
`assertEquals()` is to `assertSame()` as `==` is to `===`, so always use `assertSame()` unless you _need_ a loose comparison.
Made the unit tests compatible with PHPUnit 4.x - 7.x.
@grogy
Copy link
Member

grogy commented Sep 21, 2020

Thank you :-)

@grogy grogy merged commit 2881b9e into php-parallel-lint:master Sep 21, 2020
@jrfnl jrfnl deleted the feature/update-unit-tests branch September 21, 2020 19:25
@jrfnl jrfnl added this to the 1.0.0 milestone Dec 10, 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