Problem/Motivation
\Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations() allows us to skip deprecations. In an ideal world we wouldn't have this. But we have to content with twig 2 -> 3 deprecations and sf 4 -> 5 and 5 -> 6 etc. And sometimes we won't be able to manage the change without a major release so the previous release might have to skip such deprecations.
Proposed resolution
Allow skipping deprecations in unit tests - like we can for other types of testing.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
N/a
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 3031577-4-25.patch | 6.21 KB | alexpott |
| #22 | 3031577-4-22.patch | 5.97 KB | alexpott |
| #22 | 18-22-interdiff.txt | 891 bytes | alexpott |
| #19 | interdiff-3031577-14-18.txt | 1.66 KB | lendude |
| #18 | 3031577-18.patch | 5.96 KB | lendude |
Comments
Comment #2
alexpottHere's the patch from #3029197-22: [symfony 5] Class implements "Symfony\Component\DependencyInjection\ResettableContainerInterface" that is deprecated since Symfony 4.2, use "Symfony\Contracts\Service\ResetInterface" instead without any other changes.
Comment #3
alexpottTest only patch is the interdiff.
Comment #5
gábor hojtsyLooks good to me and already was reviewed in part in #3029197: [symfony 5] Class implements "Symfony\Component\DependencyInjection\ResettableContainerInterface" that is deprecated since Symfony 4.2, use "Symfony\Contracts\Service\ResetInterface" instead. Adding some tags and removing needs tests since it has tests.
Comment #6
larowlanFixed on commit
Committed c52175d and pushed to 8.7.x. Thanks!
Comment #8
alexpottWhoops
Also when running a test like
core/modules/aggregator/tests/src/Functional/AddFeedTest.phpI'm seeingTHE ERROR HANDLER HAS CHANGED!outputted at the end of the test. That's not right. Going to revert to address this.Comment #10
gábor hojtsyComment #11
wim leers@catch just pointed me here from #3034015: Class to test deprecation error for deprecated trait triggers deprecation error itself, which may be a symptom of this.
Comment #12
gábor hojtsyDiscussed this today, may help people working on this issue:
Comment #14
alexpottOkay I've tried to reproduce what I saw after this was committed. I've run core/modules/aggregator/tests/src/Functional/AddFeedTest.php all ways up via run-tests.sh and phpunit and it's not happening for me. I have no idea how I saw what I was seeing. But DrupalCI tests did not fail and
THE ERROR HANDLER HAS CHANGED!does not appear in DrupalCI output anywhere so I think we should assume that this was down to an environment error on my behalf. Sorry for the jittery revert - I think it might have been because all the mess with Extension objects in 8.6.x had me on edge for making a wide ranging mistake.Here's a patch with the erroneous @todo removed. What a comment there would say is covered in way more depth by this comment that the patch already contains:
The patch also includes @larowlan's on commit fixes from #6.
Comment #15
gábor hojtsySuperb, thanks! Let's get this in for the 8.7 beta then :)
Comment #16
mikelutz@alexpott Is it possible you were working on this patch in conjunction with symfony 4 testing, and were seeing the errors when you updated your dependencies to symfony 4.2? I am still seeing "THE ERROR HANDLER HAS CHANGED" locally with this patch, but only when using symfony 4 libraries. I'm seeing it in RecursiveContextualValidatorTest at least, at the moment.
Comment #17
lendudeI can reproduce #16 using the latest patch here and the latest patch on #2976394: Allow Symfony 4.4 to be installed in Drupal 8
Comment #18
lendudeThis happens on all tests with multiple test methods. I think because the restore_error_handler() is done after each method, but we were only setting the new error handler on the start of the test run. Making sure that set_error_handler($deprecation_handler); is done for every test method seems to clear this up.
Comment #19
lendudemissing interdiff
Comment #20
catchNice find with #18. Marking RTBC. Kicked off a couple of extra test runs.
Comment #21
catchComment #22
alexpottFixing PHP7.3-dev test. We don't need to register an error handler if \Drupal\Tests\Listeners\DeprecationListenerTrait::deprecationStartTest() is called for a test suite. This should only be done when we're handling a real test.
Comment #23
catchHappy to commit this once #22 comes back green.
Comment #24
mikelutzComment #25
alexpottRerolled.
Comment #26
mikelutzComment #27
catchCommitted 51cc668 and pushed to 8.8.x. Thanks!
Moving to 'to be ported' against 8.7.x for cherry-pick after the beta freeze.
Comment #29
catchCherry-picked to 8.7.x