Skip to content

[Bridge/PhpUnit] Add PHPUnit 6 support #21694

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

Merged
merged 1 commit into from
Feb 21, 2017

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Feb 20, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21125
License MIT
Doc PR -

This PR makes our phpunit bridge compatible with all namespaced versions of phpunit, from 4.8.35 to 6.
It takes another approach than #21668 and #21221, thus replaces them.
Tested locally : tests pass when using phpunit 5.7, and fails with v6.0 because our own test suite is not yet compatible with it - but at least it runs nice.
If this were handled as usual Symfony component, we would consider some changes to be BC breaks. But in this specific case - a phpunit bridge - it makes no sense to me to apply the bc policy here. I added @final and @internal annotations to make this clearer.

\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
} else {
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\DeprecationErrorHandler'] = 1;
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

why not using ::class here ?

Copy link
Member Author

@nicolas-grekas nicolas-grekas Feb 21, 2017

Choose a reason for hiding this comment

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

In fact I fogot that the bridge needs to be PHP 5.3 compatible, so I removed all the ::class

@peterrehm
Copy link
Contributor

peterrehm commented Feb 21, 2017

Awesome 👍

@@ -41,6 +41,8 @@ public static function register($mode = 0)
return;
}

$UtilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\';
Copy link
Member Author

@nicolas-grekas nicolas-grekas Feb 21, 2017

Choose a reason for hiding this comment

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

Note that I used this upper-first convention in this PR for the compatibility variables that hold the class names to use

@garak
Copy link
Contributor

garak commented Feb 21, 2017

+1 for not applying BC policy

@stof
Copy link
Member

stof commented Feb 21, 2017

What are the BC breaks here ?

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Feb 21, 2017

@stof the type hints on the listener methods and the parent class of the TextUI classes - which all switch to namespaces when phpunit 6 is used

@stof
Copy link
Member

stof commented Feb 21, 2017

Well, the typehints are OK IMO. People are not expected to extend these classes, and the calling code is PHPUnit itself. And the signature comes from PHPUnit anyway.
As long as there is no BC break for people registering the listener in their phpunit.xml config, this is fine with me.

@nicolas-grekas
Copy link
Member Author

Same to me, that's what is done here :)

@nicolas-grekas nicolas-grekas merged commit 9e0745c into symfony:master Feb 21, 2017
nicolas-grekas added a commit that referenced this pull request Feb 21, 2017
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Bridge/PhpUnit] Add PHPUnit 6 support

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21125
| License       | MIT
| Doc PR        | -

This PR makes our phpunit bridge compatible with all namespaced versions of phpunit, from 4.8.35 to 6.
It takes another approach than #21668 and #21221, thus replaces them.
Tested locally : tests pass when using phpunit 5.7, and fails with v6.0 because our own test suite is not yet compatible with it - but at least it runs nice.
If this were handled as usual Symfony component, we would consider some changes to be BC breaks. But in this specific case - a phpunit bridge - it makes no sense to me to apply the bc policy here. I added `@final` and `@internal` annotations to make this clearer.

Commits
-------

9e0745c [Bridge/PhpUnit] Add PHPUnit 6 support
@nicolas-grekas nicolas-grekas deleted the phpunit6-bridge branch February 21, 2017 10:51
nicolas-grekas added a commit that referenced this pull request Feb 21, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

Use PHPUnit 6.0 on PHP 7.* test lines

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | need #21694 first
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

96ecd3c Use PHPUnit 6.0 on PHP 7.* test lines
@garak
Copy link
Contributor

garak commented Mar 6, 2017

Just tried the latest update with phpunit 6, I'm getting PHP Fatal error: Uncaught Error: Class 'PHPUnit_Util_ErrorHandler' not found in vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:73

@xabbuh
Copy link
Member

xabbuh commented Mar 6, 2017

Did you update your local installation of the bridge (composer update symfony/phpunit-bridge)?

@garak
Copy link
Contributor

garak commented Mar 6, 2017

Here are relevant parts from my composer show:

phpunit/phpunit 6.0.8
symfony/phpunit-bridge v3.2.4
symfony/symfony v2.8.18

@xabbuh
Copy link
Member

xabbuh commented Mar 6, 2017

This PR was not merged when 3.2.4 was released. You have to wait for 3.2.5 then.

@nicolas-grekas
Copy link
Member Author

In fact, this PR has been merged in 3.3,
and there is no plan to make any previous versions compatible with phpunit 6.

@garak
Copy link
Contributor

garak commented Mar 6, 2017

OK, using "symfony/phpunit-bridge": "3.3.*@dev" is working. Thanks

@aertmann
Copy link

waiting for a stable :D thanks guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants