-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Update to PHPUnit namespaces #21564
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 to PHPUnit namespaces #21564
Conversation
The FC layer is basically restricted to a few classes as you can see here: sebastianbergmann/phpunit@a55235c
In order to fully switch to namespaces we must upgrade to 6.0. Meanwhile to Bridge will not work with 6.0. |
The PHP 5.3 test fails due to the wrong phpunit version. |
Well, you say you are replacing #21540, but our remarks on it are still valid. We have more public base test cases (and we have some listeners in the PHPUnit bridge) |
@stof Yes. Sorry, it looks like I did not elaborate enough information about your Bridge remark. The issue is since only the above mentioned 4 classes are in the FC layer, the Bridge cannot be updated to 6.0 as it uses the following classes:
Are those the listeners/handlers you meant? I do not see a way other then adding classes to the bridge which should then work like the FC layer here sebastianbergmann/phpunit@a55235c. |
I would think all the other remarks are included in the PR. |
@peterrehm it cannot be switched to namespaces entirely to add compat, I know. But several places can be changed. And we also have base test cases elsewhere than the KernelTestCase (I know that the Form and Validator components have some) |
How about migrating at least ALL those 4 classes to the namespaced version that the FC layer provides? |
@@ -13,6 +13,7 @@ | |||
|
|||
require_once __DIR__.'/Fixtures/includes/foo.php'; | |||
|
|||
use PhpUnit\Framework\TestCase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong namespace. It is PHPUnit
(same in many files, and it breaks on the CI server)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with the Migration of the Components
And |
I dont get why the PHP 7 tests are failing, on my local machine I do not have any issues. |
/ping @symfony-deciders Any remarks? Can we get this merged? |
If this gets merged, due to the new conflicts with the older PHPUnit versions, I can completely rewrite my PR for the PHPUnit bridge too (#21221) |
composer.json
Outdated
@@ -24,6 +24,9 @@ | |||
"twig/twig": "~1.28|~2.0", | |||
"psr/log": "~1.0" | |||
}, | |||
"conflict": { | |||
"phpunit/phpunit": "< 4.8.35 || >=5.0 <=5.4.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symfony 2.7 supports php 5.3
This rule prevent people to install a version of phpunit compatible with php < 5.6 alongside Symfony
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not as it allows 4.8.35?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I missed the strict comparison
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should written as <4.8.35|<5.4.3,>=5.0
for consistency with what we do elsewhere IMHO
If this PR break unit tests for a supported version, you should find a way to fix it |
@jderusse As mentioned I do not get why they are failing, it might be related to the rebuild of the bridge, the subtree split, etc. Feel free to take over if you know better. |
@@ -1,7 +1,7 @@ | |||
#!/usr/bin/env php | |||
<?php | |||
|
|||
// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/4f2aa873d2872a3b9782b25879fd628a0c418bc9 | |||
// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/d3157d942a4590121dfd23f9cadf519ca6ad4ac7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not necessary. The issue with the failing tests is that the PhpUnitBridge itself checks whether or not it needs an update. However, this doesn't work here as the simple-phpunit
file is part of the bridge installed as a vendor library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still is necessary I think to trigger a phpunit cache invalidation on appveyor.
I cleared the phpunit cache and restarted tests. There are still a few failures to take care of. |
Hm, when quickly scanning the logs I do not understand the reason for the failures. I see some missing autoloadphp's and some command failures. Do you have a clue what the reason might be? |
Dunno yet about the autoload failure. |
Actually not at all:
I tried some adjustment, it just makes no sense. Localy the tests pass on PHP7 as well. |
With the latest commits I fixed 5.3 which IMHO makes no sense but who cares. No there are the issues with 7.x ledt which seem more related with the test setup rather than the actual changes? Is this maybe due to the subtree split? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - would be great to have a rule on fabbot that ensures that we won't introduce non-namespaced phpunit things anymore thought.
composer.json
Outdated
@@ -24,6 +24,9 @@ | |||
"twig/twig": "~1.28|~2.0", | |||
"psr/log": "~1.0" | |||
}, | |||
"conflict": { | |||
"phpunit/phpunit": "< 4.8.35 || >=5.0 <=5.4.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should written as <4.8.35|<5.4.3,>=5.0
for consistency with what we do elsewhere IMHO
travis failures are unrelated (known composer bug when too many local packages are created) |
@nicolas-grekas Updated the constraint. For now some PHPUnit_ classes are still needed due to the limited scope of the FC layer. If we manage to provide a full FC layer we could enforce that. Next would be to update the bridge to full PHP6 compatibility. |
Just did that: |
@nicolas-grekas what about the usages of static methods in the bridge, like those?
We don't have an FC layer for that.. |
See my attempt here: sebastianbergmann/phpunit#2502 Lets see how it goes. |
@nicolas-grekas Rebased. Once this is merged I would like to check first the 3.x branches then we should care about the bridge. Once we have this done we could look into how to prevent those issues. Does fabbot rely on php-cs-fixer? |
@peterrehm I this get merged, I would like to help with the bridhe. |
@Jean85 Lets discuss once this is done. I think we have to look into providing a FC layer as PHPUnit does. |
👍 |
👍 The changes look good. I just don't understand why the build is failing. |
👍 |
Thank you @peterrehm. |
This PR was squashed before being merged into the 2.7 branch (closes #21564). Discussion ---------- Update to PHPUnit namespaces | Q | A | ------------- | --- | Branch? | 2.7+ | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21534 | License | MIT | Doc PR | - Replaces #21540 @nicolas-grekas Is the update of the cache-id like this sufficient? Do we maybe have to specifiy 4.8.35 in simple-phpunit? Commits ------- ddd2dff Update to PHPUnit namespaces
@peterrehm can you please check branch 2.8 now? I just merged 2.7 into 2.8. Thanks for your help. |
This PR was squashed before being merged into the 2.8 branch (closes #21663). Discussion ---------- Updated PHPUnit namespaces | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Follow Up of #21564 Commits ------- 205ced4 Updated PHPUnit namespaces
This PR was merged into the 2.7 branch. Discussion ---------- Add missing conflict rules for phpunit | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - We forgot them in #21564 Commits ------- 3e83e02 Add missing conflict rules for phpunit
This PR was merged into the 3.2 branch. Discussion ---------- Use PHPUnit 5.4 instead of 5.3 | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | PHPUnit 5.3 doesn't have the forward compatibility layer for PHPUnit 6 so that `PHPUnit\Framework\TestCase` can be used instead of `PHPUnit_Framework_TestCase`. This generates an error when upgrading to Symfony 3.2.5 without forcing the `SYMFONY_PHPUNIT_VERSION` const: ``` Class 'PHPUnit\Framework\TestCase' not found in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php on line 25 ``` This was introduced by c9684ad (from #21564) in 3.2.5 (Discussion started on Slack: https://symfony-devs.slack.com/archives/support/p1489058629011510) Commits ------- fca16ba Use PHPUnit 5.4 instead of 5.3
Replaces #21540
@nicolas-grekas Is the update of the cache-id like this sufficient? Do we maybe have to specifiy 4.8.35 in simple-phpunit?