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

Add support for PHPUnit version 9 #1053

Merged
merged 8 commits into from
May 14, 2020

Conversation

martinssipenko
Copy link
Contributor

@martinssipenko martinssipenko commented Apr 29, 2020

This adds support for PHPUnit version 9.

PHPUnit version 9.1.2 had a breaking change in then @internal marked Blacklist class, which was addressed in 9.1.3.

Fixes #1048

$this->assertArrayNotHasKey(\Mockery::class, \PHPUnit\Util\Blacklist::$blacklistedClassNames);
$this->listener->startTestSuite($suite);
$this->assertSame(1, \PHPUnit\Util\Blacklist::$blacklistedClassNames[\Mockery::class]);
if (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better to split this up into two tests and skip one of them depending on PHPUnit version?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davedevelopment I can't find an easy way to check the minimum required version of PHPUnit is 9.1.3, so maybe we can leave this as is?

Copy link
Collaborator

@davedevelopment davedevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this

@@ -37,4 +37,22 @@ protected function mockeryTestSetUp()
protected function mockeryTestTearDown()
{
}

public function expectExceptionMessageRegEx($regularExpression)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it have been better to leave the method name as expectExceptionMessageRegExp here? Or was there a clash in the signatures over the course of different PHPUnit versions?

The travis build is failing because there are still some tests in there call expectExceptionMessageRegExp.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davedevelopment Yes there are issues with signatures. I'll try to fix travis build so it passes.

$this->assertArrayNotHasKey(\Mockery::class, \PHPUnit\Util\Blacklist::$blacklistedClassNames);
$this->listener->startTestSuite($suite);
$this->assertSame(1, \PHPUnit\Util\Blacklist::$blacklistedClassNames[\Mockery::class]);
if (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree 👍

* master:
  Revert expectExceptionMessageMatches()
  Fix DocBlocks for variadic arguments
  Start 1.3.2 changelog.
  Tweak test name for specificity.
  Fix bug in anyOtherArguments matching logic.
  Fix indentation in new test to match existing indentation.
  Add new failing test and fix error in test causing false success.
  Update usages of deprecated PHPUnit expectation.
  Update installation.rst
* master:
  Update type hints to be more specific
  Fix type hint on shouldNotRecieve() argument
  Slim down mockery when loaded as a dependency
@martinssipenko
Copy link
Contributor Author

@davedevelopment the build is now green, could you please take a look at this again? I would love to see this released as it currently prevents people from upgrading to PHPUnit version above 9.1.2.

@davedevelopment
Copy link
Collaborator

@martinssipenko I was just about to pull this branch and finish it myself! Will review now.

@davedevelopment davedevelopment merged commit f24033d into mockery:master May 14, 2020
@martinssipenko martinssipenko deleted the phpunit9 branch May 14, 2020 08:34
@davedevelopment
Copy link
Collaborator

Merged. I'm going to take a look at dropping our list of supported PHP and PHPUnit versions today and will probably make a release later.

@martinssipenko
Copy link
Contributor Author

Sweet, yeah the list of supported PHP version is quite long and is starting to cause much pain.

@davedevelopment
Copy link
Collaborator

PR created #1059

One thing I'm going to revert from this, those helpers for the regExp methods should be on a test case specifically for the mockery tests, rather than the MockeryTestCase, which is for consumers first and foremost. We don't want to have to support those methods ourselves.

@martinssipenko
Copy link
Contributor Author

Maybe they are not needed at all if support for older version, where they were not present or were named differently, is dropped.

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.

Uncaught Error: Access to undeclared static property: PHPUnit\Util\Blacklist::$blacklistedClassNames
2 participants