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.
Problem/Motivation
If you run phpunit test via ./vendor/bin/phpunit -c ./core --testsuite unit
they will fail with:
There were 2 failures:
1) Drupal\Tests\Core\Test\PhpUnitBridgeTest::testDeprecatedClass
Failed asserting that format description matches text.
--- Expected
+++ Actual
@@ @@
@expectedDeprecation:
-%A Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass is deprecated.
+
/Volumes/devdisk/dev/sites/drupal8alt.dev/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListenerTrait.php:286
/Volumes/devdisk/dev/sites/drupal8alt.dev/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListener.php:57
2) Drupal\Tests\link\Unit\Plugin\migrate\cckfield\LinkCckTest::testProcessCckFieldValues
Failed asserting that format description matches text.
--- Expected
+++ Actual
@@ @@
@expectedDeprecation:
-%A CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
-%A MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.
-%A
+ LinkField is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d6\LinkField instead.
+
/Volumes/devdisk/dev/sites/drupal8alt.dev/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListenerTrait.php:286
/Volumes/devdisk/dev/sites/drupal8alt.dev/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListener.php:57
Proposed resolution
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#13 | 2933991-13.patch | 6.72 KB | alexpott |
#13 | 9-13-interdiff.txt | 589 bytes | alexpott |
#9 | 2933991-9.patch | 6.95 KB | alexpott |
#9 | 8-9-interdiff.txt | 2.62 KB | alexpott |
#8 | 4-8-interdiff.txt | 946 bytes | alexpott |
Comments
Comment #2
neclimdulThanks alex. I took a stab at this but either I'm doing something wrong or it is a bit tricky. Fixing one problem causes different failures.
Comment #3
alexpottSo we can fix
Drupal\Tests\Core\Test\PhpUnitBridgeTest
really simply. But the other one is an interesting tangle because even making it run in a separate process doesn't fix it because the @covers checking in \Drupal\Tests\Listeners\DrupalStandardsListenerTrait causes the class to be loaded. Not sure how to get around that. Ideally\Drupal\Tests\Listeners\DrupalStandardsListenerTrait
would not trigger deprecation errors.Comment #4
alexpottThis is green... what fun. There's a bug in Symfony's PHPUnit deprecation counter whereby you only need to match on one expected deprecation for a pass. Given their focus on unit tests it's obviously the multiple deprecation testing probably needs more test coverage.
Comment #6
neclimdulhahahaha see... tricky.
"you only need to match on one expected deprecation for a pass."
Not sure about how the deprecation matching is implemented but are they handled through exceptions? If so the first one will stop execution and you can never have more then one match so matching any expected exception makes sense.
Comment #7
neclimdulI spent some time banging on this and am basically cross eyed and delirious now so documenting what I've seen.
1) Obviously not exceptions. You're working with the error handler to fix things. derp on my part.
2) That error handling change is the "problem". Removing it "fixes" the tests.
3) "problem" and "fixes" because I don't think they ever tested what we thought. They tested the coverage weirdness because removing the covers annotations on a clean install causes the assertion to fail in both run-test.sh and phpunit
4) There _should_ be a deprecation to test in both of these tests. Neither work and it seems connected to the subprocess phpunit serialization magic which might not be working correctly in Drupal's test suite. Inspecting the serialized value reveals an empty array.
All of this to say, I think this patch might be fine the way it is but our deprecation testing doesn't seem to work 100%. Bonus observation, since unit tests run in their own process on testbot and their testing works, it is likely something kernel tests do specifically that is breaking things.
Comment #8
alexpottAh the fun. So we shouldn't be skipping deprecations when we are dealing with a legacy test. The only reason this test generates deprecation notices in HEAD atm is the Drupal standards checker which is obviously nonsense.
Comment #9
alexpottSome minor improvements.
Comment #10
neclimdulThank god you knew where to look because I was going in circles trying to figure out how the interprocess communications wasn't working.
Think this is the only thing keeping it from being RTBC
Comment #11
alexpott@neclimdul I think we should just have a comment for that. It needs to be in a separate process because some other test is also loading the code so the deprecation error is not triggered unless this is in a separate process.
Comment #12
neclimdulcurrently they're not running in a separate process though. there's an "a" in front.
Comment #13
alexpott@neclimdul lol - yeah right - at one point that was necessary but once I fixed the standards checker to ignore deprecations it was no longer necessary... new patch.
Comment #14
neclimdul:-D wfm. No real change from previous patch so going to assume it'll pass and preemptively RTBC.
Comment #15
larowlanCrediting @neclimdul for the time spent on #7
Comment #17
larowlanCommitted as 891c39b and pushed to 8.5.x
Thanks folks
Comment #18
Wim LeersShouldn't we have a CR for these? Apparently I can write test methods like
testLegacySomethingBlah()
and it won't skip deprecations?Also: we have nothing that actually uses this?
Comment #19
alexpott@Wim Leers this is not really from us this is from Symfony. See https://github.com/symfony/phpunit-bridge/blob/master/DeprecationErrorHa... - nothing has actually changed here. In order to get Symfony's deprecation testing we can't have test methods or classes with legacy in the name as this is deprecated (by Symfony).
Comment #20
Wim LeersAhhh! A comment indicating that that's there just to match upstream logic would've helped make that clear: wouldn't have asked then.
Comment #22
narasimhan_gobear CreditAttribution: narasimhan_gobear commentedHi all : Is there a ticket for following the upstream changes and adding them later within
phpunit
?Edit : I made the above comment before learning about
symfony/phpunit-bridge
. Please ignore