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
setUp() methods in tests need a void return type for D10 compatibility.
Proposed resolution
Add them.
Remaining tasks
- Wait until we no longer support versions of Drupal that run on versions of PHP that don't handle return types.
- Review / re-test.
- Commit.
User interface changes
N/A
API changes
Only in tests.
Comment | File | Size | Author |
---|---|---|---|
#15 | 3163415-15.patch | 5.34 KB | bojanz |
#14 | 3163415-14.patch | 5.51 KB | bojanz |
#12 | 3163415-12.patch | 5.7 KB | Pooja Ganjage |
#6 | 3163415-6.patch | 4.82 KB | pavnish |
Comments
Comment #2
dwwThanks for opening this.
Please combine all such "replace AssertLegacyTrait:*" into a single issue (here). We don't want/need separate issues for each kind of assertion.
Cheers,
-Derek
Comment #3
dww(As a reasonable rule of thumb -- if core put all the changes in a single CR, all those changes can be fixed in a single issue in a contrib). ;)
Thanks again,
-Derek
Comment #4
pavnish CreditAttribution: pavnish at Srijan | A Material+ Company for Drupal India Association commentedComment #5
pavnish CreditAttribution: pavnish at Srijan | A Material+ Company for Drupal India Association commentedComment #6
pavnish CreditAttribution: pavnish at Srijan | A Material+ Company for Drupal India Association commented@dww sorry i have not found any "AssertLegacyTrait" deprecation I have found only these deprecation errors that is related to setup method i also apologies for was created the issue with wrong tittle it's was a confusion :
Could you please conform that we can change the issue title according to setup method:
I am adding the patch for the same.
6x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\FunctionalJavascript\AddressDefaultWidgetTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
6x in DrupalListener::startTest from Drupal\Tests\Listeners
5x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Unit\Plugin\Validation\Constraint\CountryConstraintValidatorTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
5x in DrupalListener::startTest from Drupal\Tests\Listeners
4x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Functional\Views\AdministrativeAreaFilterTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
4x in DrupalListener::startTest from Drupal\Tests\Listeners
4x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Kernel\Formatter\AddressDefaultFormatterTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
4x in DrupalListener::startTest from Drupal\Tests\Listeners
2x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Functional\Views\CountrySortTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
2x in DrupalListener::startTest from Drupal\Tests\Listeners
2x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Kernel\CountryNameTokenTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
2x in DrupalListener::startTest from Drupal\Tests\Listeners
2x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Kernel\Formatter\AddressPlainFormatterTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
2x in DrupalListener::startTest from Drupal\Tests\Listeners
1x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Kernel\Formatter\CountryDefaultFormatterTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
1x in DrupalListener::startTest from Drupal\Tests\Listeners
1x: Declaring ::setUp without a void return typehint in Drupal\Tests\address\Kernel\ZoneItemTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
1x in DrupalListener::startTest from Drupal\Tests\Listeners
Comment #7
dww@pavnish: Okay, thanks.
The issue summary template is useful. You got it by default when you created this issue, but you deleted it. ;)
Anyway, marking this postponed for now, and added this as the first remaining task:
I don't want to commit this now, since it'll break for sites trying to test on Drupal 8.8 with PHP 7.0.
Cheers,
-Derek
Comment #8
bojanz CreditAttribution: bojanz commentedOpened #3185437: Drop support for Drupal 8.8.x and PHP 7.0 for dropping 8.8 support. We now have a 1.9 release with 8.8 support, so the next one could be 8.9+.
I'm also fine with bumping the min PHP version to 7.1, since I believe 8.9 didn't do that.
Comment #9
bojanz CreditAttribution: bojanz commentedLet's continue tackling the other failures here too.
Pushed a commit for the AssertLegacyTrait errors.
Build: https://www.drupal.org/pift-ci-job/1898641
Other messages:
Current research:
Some $modules deprecations can't be fixed while we support D8. For example, the ZoneItemTest one since the test extends EntityKernelTestBase.
EventDispatcher deprecations are also tricky: https://www.drupal.org/node/3159012, probably best to leave for a D9-only future.
Comment #11
bojanz CreditAttribution: bojanz commentedPushed a commit for the $modules warnings, since, that's the time I'll have for the next 7 days.
That and the AssertLegacyTrait commit have brought us down from 12 to 9 failures: https://www.drupal.org/pift-ci-job/1898649
And here's the build for the setUp patch from #6: https://www.drupal.org/pift-ci-job/1898650
Looks like I forgot to fix $modules in CountryNameTokenTest, so that's an easy fix for next time.
Comment #12
Pooja Ganjage CreditAttribution: Pooja Ganjage at Asentech LLC commentedHi,
Creating a patch for this issue and added protected modifier that are missing.
Please review the patch.
Thanks.
Comment #13
Pooja Ganjage CreditAttribution: Pooja Ganjage at Asentech LLC commentedComment #14
bojanz CreditAttribution: bojanz commentedCommitted #3185437: Drop support for Drupal 8.8.x and PHP 7.0.
#12 can't work because it's modifying ZoneItemTest. Mentioned that in #9.
Here's a patch without that part.
Comment #15
bojanz CreditAttribution: bojanz commentedCan't touch CountryNameTokenTest either...
Comment #17
bojanz CreditAttribution: bojanz commentedWe're down from 9 deprecation fails to 6 now. I think this is as far as we can get while still supporting Drupal 8.9.
Gave commit credit to pavnish since the commit is the same as their initial patch.
Comment #19
yang_yi_cn CreditAttribution: yang_yi_cn at New/Mode commentedcan we reopen this? at least needs a different branch / release that works with Drupal 9.1 / 9.2, currently it basically doesn't support Drupal 9.1 / 9.2.
Comment #20
dww@yang_yi_cn: What do you mean? The deprecations here are things that will be removed in Drupal 10. This module absolutely works with Drupal core 9.1 and 9.2. If it generates some deprecation notices about D10, you can disable those messages or learn to ignore them. ;)
Cheers,
-Derek
Comment #21
yang_yi_cn CreditAttribution: yang_yi_cn at New/Mode commentedThe auto test does show errors like this in D9.1 (and not in D8.9):
Basically https://www.drupal.org/node/3154407 says
The signature of Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch() has changed.
Before:
After:
The order of $event and $event_name is switched, this is introduced in D9.1 / Symfony 4.x.
I actually confused this with another deprecation notice, which is about the Event class, that will be deprecated in D10 / Symfony 5.
But the dispatch event order thing I believe is something needs to be fixed now.