Skip to content

Use PSR-1 for PHPUnit TestCase #429

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

Closed
wants to merge 2 commits into from
Closed

Use PSR-1 for PHPUnit TestCase #429

wants to merge 2 commits into from

Conversation

carusogabriel
Copy link
Contributor

Use PSR-1 while extending PHPUnit TestCase class. This will help us when to migrate to PHPUnit 6, that no longer support snake case namespaces.

@alcaeus
Copy link
Member

alcaeus commented Nov 6, 2017

This needs an update of the phpunit requirement in composer.json. Not all versions that satisfy ^4.8 include the forward compatibility layer. I suggest using ^4.8.36|^5.7|^6.4 instead of ^4.8.

@carusogabriel
Copy link
Contributor Author

@alcaeus I'll update to ^4.8.36 only. PHPUnit 5 has some deprecated methods, and 6 uses PHP 7, and we will need to work on that later.

jmikola added a commit that referenced this pull request Nov 6, 2017
@jmikola
Copy link
Member

jmikola commented Nov 6, 2017

Manually merged in d4583a9. Thanks!

@alcaeus: I noticed that there were two outstanding issues with allowing ^5.7|^6.4 in composer.json:

  • We currently have a number of tests that perform no assertions (e.g. they construct an object to ensure that no exceptions are thrown for invalid arguments). PHPUnit now warns against such risky tests unless we disable the warning in our configuration.
  • We have several tests that expect a PHPUnit_Framework_Error_Warning exception (as part of their assertion for an internal PHP warning). The PHPUnit 6 compatibility layer added in 4.8.36 and 5.7.21 did not include namespaced aliases for the exception classes, so we can't generalize those tests for all three PHPUnit verisons.

For the time being, we'll need to remain on 4.8.36.

@jmikola jmikola closed this Nov 6, 2017
@alcaeus
Copy link
Member

alcaeus commented Nov 6, 2017

PHPUnit now warns against such risky tests unless we disable the warning in our configuration.

For individual tests, there is a doesNotPerformAssertions annotation you can add to the tests in question. As for the warnings, that's indeed an issue that can't be fixed - only thing you could do is adding your own compatibility layer using class_alias.

@jmikola
Copy link
Member

jmikola commented Nov 6, 2017

Sounds good. I've opened PHPLIB-294 to track that.

@carusogabriel carusogabriel deleted the phpunit branch November 6, 2017 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants