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
AssertLegacyTrait::assertFieldChecked() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->checkboxChecked() instead. See https://www.drupal.org/node/3129738
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#27 | rawdiff_22-27.txt | 6.18 KB | mondrake |
#27 | 3139428-27.patch | 58.41 KB | mondrake |
#22 | interdiff-17-22.txt | 8.74 KB | jungle |
#22 | 3139428-22.patch | 58.41 KB | jungle |
Comments
Comment #2
jungleAdding the "Deprecated assertions" tag to add this into the kanban board https://contribkanban.com/board/Deprecatedassertions
Comment #3
jungleComment #4
xjmComment #6
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedComment #7
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedPatched #3 failed to apply on 9.1.x-dev. Rerolled the patch and fixed the failed tests.
Comment #8
Bunty Badgujar CreditAttribution: Bunty Badgujar at Srijan | A Material+ Company for Drupal India Association commentedIn #7
Remove Deprecation Listener
There still
assertFieldChecked() and assertNoFieldChecked()
left. For example,core/modules/comment/tests/src/Functional/CommentAdminTest.php
Add Test for
AssertLegacyTrait::assert(No)FieldChecked()
Comment #9
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedComment #10
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedUpdated patch #7 and removed Deprecation Listener as mentioned in #8, please review.
Comment #12
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 commentedThere is mis-matching between the patch at #10 and description of this issue. Either we should update the patch or update the description. Right now i am creating new patch according to description of the issue and removing deprecation listener from core/modules/comment/tests/src/Functional/CommentAdminTest.php which was missed in patch no #7.
And there are many more deprecated methods are still present like as below.
AssertLegacyTrait::assertFieldByName() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals() instead. See https://www.drupal.org/node/3129738
AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738
AssertLegacyTrait::constructFieldXpath() is deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $this->getSession()->getPage()->findField() instead. See https://www.drupal.org/node/3129738
and many more for this we can create different issues and try to solve accordingly.
Comment #13
Bunty Badgujar CreditAttribution: Bunty Badgujar at Srijan | A Material+ Company for Drupal India Association commentedThanks for contribution @hardik_patel,
#12 still not addressed all the issues mentioned in #8.
I don't see any reason, why should we consider other deprecated function here.
Comment #14
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 commentedLast patch failed to apply , kindly follow a new patch. Deprecation error is coming in core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php file is mainly because #3139440: Replace usages of deprecated AssertLegacyTrait::buildXPathQuery() , #3139431: Replace usages of AssertLegacyTrait::assertFieldsByValue, that is deprecated and #3139442: Replace usages of AssertLegacyTrait::constructFieldXpath, that is deprecated is not fixed yet.
Let's fix them first, it will automatically gone pass.
Comment #16
jungleTrying to fix #14
Comment #17
jungleTwo \Drupal\FunctionalTests\BrowserTestBaseTest::testFieldAssertsForCheckbox(), removed one of them.
Comment #18
mondrakeThanks.
It seems overkill to have this in a foreach loop. Better two straight individual calls?
Are not we losing test coverage here? Better leave the test as-is converting the calls, and add a separate deprecation test just for the unconverted calls.
Comment #19
mondrakeAlso, the deprecation silencer in
DeprecationListener
is not removed.Comment #20
jungleThanks for reviewing @mondrake!
Re #18.2 yes, that's why two \Drupal\FunctionalTests\BrowserTestBaseTest::testFieldAssertsForCheckbox() in #16 by mistake. But later, i thought as the test is covering legacy ones, so removed it in #17. well, i will add it back.
Agree with #18.1
Comment #21
mondrake@jungle #18.2 actually I did not check if there is other test coverage for that, but now I see that the docblock says 'Tests legacy field asserts for checkbox field type.'. If we're not losing coverage of other methods, that'd be fine I guess.
Comment #22
jungleRe #21. Addressing #18, #19. Reverted the removal.
Comment #23
mondrakeThanks!
Comment #24
mondrakeComment #25
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedRerolling patch for the latest head for 9.1.x
Comment #27
mondrakeReroll of #22. #25 is likely a random failure, but I rerolled from last green patch.
Comment #28
alexpottCommitted 09c6b3d and pushed to 9.1.x. Thanks!
There's already a few conflicts on 9.0.x so backporting this problem is not worth it.