Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As a follow up for #2110153: Upgrade phpunit/php-file-iterator from 1.3.3 to 1.3.4, here's a patch that updates all the other phpunit components we're using. Let's update these things and test how decoupled our use of these components are. We shouldn't break anything by upgrading minor versions.
Comment | File | Size | Author |
---|---|---|---|
#57 | interdiff.txt | 682 bytes | olli |
#57 | 2114823-57.patch | 726 bytes | olli |
#56 | 2114823-56.patch | 781 bytes | olli |
#53 | simpletest-2114823-53.patch | 1.63 KB | tim.plunkett |
#46 | 2114823.45.patch | 6.01 MB | alexpott |
Comments
Comment #1
cosmicdreams CreditAttribution: cosmicdreams commentedHere's a patch that updates the following:
phpunit/php-timer => (1.0.5)
phpunit/php-token-stream => (1.2.1)
phpunit/php-code-coverage => (1.2.13)
phpunit/phpunit =>(3.7.28)
Comment #2
cweagansPHPunit 4.0.0 was released. https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-f...
Comment #3
cosmicdreams CreditAttribution: cosmicdreams commentedOh I hadn't realized I had already opened this issue. Cool.
Now that we have composer, updating PHPUnit is one composer -update operation away. PHPUnit does state that the 3.7 version of their suite is LTS. It's not exactly clear what they mean by LTS and how much longer we should expect it to be supported.
Either way, 4.0 is the new shiny and there are a few things in the Changlog that sound like it may interest us here. Specifically:
Implemented #773: Recursive and repeated arrays are more gracefully when comparison differences are exported.
Implemented #813: Added @before, @after, @beforeClass and @afterClass annotations.
Implemented #838: Added a base test listener.
Implemented #869: Added support for the adjacent sibling selector (+) to PHPUnit_Util_XML::findNodes().
Implemented #871: Add Comparator for DateTime objects.
Implemented #877: Added new HTML5 tags to PHPUnit_Util_XML::findNodes().
Fixed #240: XML strings are escaped by removing invalid characters.
Full changelog: https://github.com/sebastianbergmann/phpunit/wiki/ChangeLog-for-PHPUnit-4.0
Release notes: https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-f...
Comment #4
cosmicdreams CreditAttribution: cosmicdreams commentedMarking this one as a duplicate of #2159845: Upgrade to PHPUnit 4
Comment #5
webchickThis one's older, let's use this issue.
Comment #6
webchickOops. We need a new patch.
Comment #7
tim.plunkettRemoving the staticExpects in AccessManagerTest and ReverseProxySubscriberUnitTest does not make the tests fail, but it might affect what lines of code they cover.
However, the staticExpects in EntityManagerTest is a problem.
In EntityManager::buildBaseFieldDefinitions() it calls
$base_field_definitions = $class::baseFieldDefinitions($entity_type);
and then foreaches over it. Removing the staticExpects makes this null, so you get a niceInvalid argument supplied for foreach()
.Not sure what to do there.
Comment #8
cosmicdreams CreditAttribution: cosmicdreams commentedI'll try to put together the patch to update phpunit tonight (unless someone beats me to it). Hopefully after that, we'll have specific test failures to address.
Comment #9
Xano@cosmicdreams: do you have something already, or can I safely make a patch without being in your way?
Comment #10
cosmicdreams CreditAttribution: cosmicdreams commentedYou can, but beware of Dragons. I haven't contributed back a patch for this because TONS of things break by moving to PHPUnit 4. I've been trying to diagnose what's wrong and what needs to be fixed but it's a bit beyond me.
Comment #11
dawehner@cosmicdreams
Do you have a list of tests which fail after the update?
Comment #12
cosmicdreams CreditAttribution: cosmicdreams commentedIt's the test runner that fails. so no I do not.
Comment #13
dawehnerWhath happens if you use the native phpunit test runner?
Comment #14
neclimdulnothing currently, it somehow hands off to Drupal's runner. If you update composer.json and run composer update it will use the 4.0 runner and it fails because we use the goofy staticExpects method that is gone because it was apparently sort of broken. I was going to take a swing then saw this was sprinkled in our base entity tests and I don't have the chops to testing EntityAPI.
http://phpunit.de/manual/current/en/appendixes.upgrading.html#appendixes...
Comment #15
XanoComment #16
cosmicdreams CreditAttribution: cosmicdreams commentedHere's a patch that updates to PhpUnit 4.1.0. When I run the tests here's the error I get:
Comment #17
ParisLiakos CreditAttribution: ParisLiakos commentedComment #18
neclimdulYeah thats the error I mentioned. staticExpects was removed as is documented in the upgrade guide I posted.
Fatal error: Call to undefined method Mock_Request_5a8ef19b::staticExpects() in
Comment #19
tim.plunkettI called it out in #7 as well.
Comment #20
cosmicdreams CreditAttribution: cosmicdreams commentedSo it seems like the last good direction we got on this issue was from #7 where it sounds like tim's calling for a rewrite of the EntityManagerTest. Seems like that is what's needed in order to advance this issue. I'm not the best equipped to do that but I'll give it a shot over the next week.
Comment #21
XanoThis updates PHPUnit to 4.1.1. I will continue working on replacing
staticExpects()
usages.Comment #23
XanoThis patch contains the upgrade and the necessary
staticExpects()
conversions.Comment #25
XanoComment #27
neclimdulSome tests ran through with this. Lets see how testbot likes it.
Comment #29
XanoComment #30
ParisLiakos CreditAttribution: ParisLiakos commentedcool its green. can we have the changes excluding
/vendor
so dreditor doesnt crash?Comment #31
sunIs it possible to split those functional test changes into a separate issue?
Comment #32
XanoWhat changes? There is nothing in here that isn't necessary for the upgrade.
Comment #33
neclimdulI think he meant fix the tests first since the changes will work in the current version of phpunit, then do the upgrade changes.
Comment #34
XanoPostponed on #2278705: Make all tests compatible with PHPUnit 4.
Comment #35
alexpottHere is a patch to only upgrade PHPUnit and not touch any other files.
Instructions to generate this patch:
Comment #36
XanoThank you for the instructions!
Comment #37
neclimdul#2278705: Make all tests compatible with PHPUnit 4 is in so we'll need a re-roll and this is back active!
Comment #38
cosmicdreams CreditAttribution: cosmicdreams commentedi must be having problems with the git or something because I can't seem to get all the folder renaming to commit.
Comment #39
neclimdulYeah I couldn't apply it either. I had to export with --binary to get the patch to re-apply. Lets see what the bot says.
Comment #41
neclimdulgugh, the simpletest.module fix.
Comment #43
BerdirLooks like the latest patches have the whole zend framework in them, I also tried the approach in #35 manually and it resulted in the same.
Comment #44
alexpottDunno why but the steps in 35 still work for me.
Comment #46
alexpottNow including the simpletest.module fix too :) And patch made with --binary option too... hence the size increase.
Comment #47
alexpottAfter applying the patch with -a the following changes outsite /core/vendor/phpunit and core/vendor/sebastian are made:
Which are all expected.
Comment #48
XanoThe patch adds a few new packages to the
sebastian
vendor directory, but since they are all licensed under the BSD-3, this still allows us to add the code to our own repo. Other than that, the patch only changes core's composer.json and simpletest.module, and updatesphpunit
packages, so I think we're good to go!Thanks for helping move this forward, people!
Comment #50
XanoIgnore that. It's feedback for an old patch.
Comment #51
webchickHoly crow. This patch officially wins the "Most Deceptively Simple Looking But Biggest Pain In The Rear To Actually Commit Patch" award. ;)
For some reason—I suspect because I'm on Mac OS which is case-insensitive, and there are file renames here—the patch would not apply for me, even with
git apply --binary --index
. It complained loudly about a bunch of files already in my working directory. Neither agit clean -df; git reset --hard
nor a freshgit clone
resolved the matter, nor did blitzing the core/vendor/phpunit dir.What we ended up resorting to was chx applying the patch on his local clone of D8 and then tarring it up and sending it to me over Skype for me to execute on my machine. :P However, because of various reasons, that needed to actually be done 3(!) times, at ~145M of transfer a pop. :)
Long story short, committed and pushed to 8.x, and I added chx to the commit credit here, because without him, this never would've been committed, at least by me. :P Thanks!
Comment #53
tim.plunkettAll PHPUnit tests are being ignored by run-tests.sh now.
The last core test run before this patch had ~72000 passes. The first one after this had ~67000, and we have ~5000 unit test assertions.
The typehint changes to simpletest.module explains the problem. What we have as $test_suite is actually an array of test suites.
We need to retrieve the test from the suite.
If this patch has ~72000 passes, it's good.
Comment #54
tim.plunkettHmmmm, it didn't get back to 70K, but I do now see unit tests like AddRoleUserTest and LocalActionManagerTest in the list, which aren't on https://qa.drupal.org/8.x-status.
So maybe my math is off?
Comment #55
BerdirYeah, we're still missing tests.
I can't see a pattern yet, but one that is missing and that's contributing 2800 assertions is SystemControllerTest. What's weird is that I can run it if I pass it explicitly but the discovery doesn't find it:
Finds nothing. But...
Comment #56
olli CreditAttribution: olli commentedCan we do this?
Comment #57
olli CreditAttribution: olli commentedOr without is_subclass_of().
Comment #58
XanoWhy does
is_subclass_of()
work, whileinstanceof
doesn't?Comment #59
tim.plunkettBecause $test is PHPUnit_Framework_TestSuite, while $name is the test class itself.
#57 works great, and has 72K passes, and
php core/scripts/run-tests.sh --list | grep SystemControllerTest
works for it. Thanks @olli!Comment #60
webchickI knew there was no way we were getting off that easily. :)
Committed and pushed to 8.x. Thanks so much for the quick find + fix!
Comment #62
tim.plunkettThanks @webchick!
Comment #63
sunFollow-up: #2294731: Simpletest fails to run PHPUnit on Windows