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::assertRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3139409
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3139409-9.2.x changes, plain diff MR !1035
- 3139409-replace-usages-of changes, plain diff MR !1026
Comments
Comment #2
mondrakeKick-off.
Comment #3
mondrakeComment #5
jungleAdding the "Deprecated assertions" tag to add this into the kanban board https://contribkanban.com/board/Deprecatedassertions
Comment #6
shobhit_juyal CreditAttribution: shobhit_juyal as a volunteer and at Srijan | A Material+ Company commentedComment #7
shobhit_juyal CreditAttribution: shobhit_juyal as a volunteer and at Srijan | A Material+ Company commentedI have added the patch which only includes test case fixes in #2.
Needs Review
Comment #9
shobhit_juyal CreditAttribution: shobhit_juyal as a volunteer and at Srijan | A Material+ Company commentedPrevious patch has some issue, uploaded new patch
Comment #10
shobhit_juyal CreditAttribution: shobhit_juyal as a volunteer and at Srijan | A Material+ Company commentedTests passed, moving the ticket for review.
Comment #11
mohrerao CreditAttribution: mohrerao as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedI can still see many instances of assertRaw in core.
Comment #12
nitesh624Comment #13
nitesh624Replace remaining of assertRaw() as addressed in #11.
also can't create interdiff as patch in #8 needs reroll. see below screenshot
Comment #14
nitesh624Comment #15
nitesh624Re the comment by @mohrerao in #11.
assertRaw() is not available in kernel tests. please see https://api.drupal.org/api/drupal/core%21tests%21Drupal%21KernelTests%21...
So i just reroll the patch in #9
Also i could not generate interdiff with #9 as written earlier
Comment #16
nitesh624Comment #17
nitesh624Comment #18
shobhit_juyal CreditAttribution: shobhit_juyal as a volunteer and at Srijan | A Material+ Company commentedHi, its strange why the patch is not applying...
@nitesh624, please see the snapshot
Comment #19
nitesh624hi @shobhit_juyal its because there is some commit has been pushed on to dev after my patch completed run. so in this situation core committers only take appropriate action
Comment #20
nitesh624Rerolled the patch #15
Comment #21
nitesh624Comment #22
nitesh624Comment #23
daffie CreditAttribution: daffie commentedPatch no longer applies.
Comment #24
shobhit_juyal CreditAttribution: shobhit_juyal as a volunteer and at Srijan | A Material+ Company commentedNeeds review.
Comment #25
shobhit_juyal CreditAttribution: shobhit_juyal as a volunteer and at Srijan | A Material+ Company commentedComment #26
nitesh624RTBC +1
Comment #27
munish.kumar CreditAttribution: munish.kumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedHi @shobhit_juyal, The latest patch has one coding standard issue, So I have fixed this here is the patch and the interdiff.
Comment #28
mohrerao CreditAttribution: mohrerao as a volunteer and at Srijan | A Material+ Company for Drupal India Association commented3139409-27.patch looks good. RTBC again
Comment #29
alexpottThe patch does not apply.
Also we need to remove
From \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations()
Comment #30
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedComment #31
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedRerolled patch #27 and also done changes as mentioned in #29, please review.
Comment #33
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedComment #34
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedTrying to fix failed test cases in #31.
Replaced assertnoraw() deprecated function.
Comment #36
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedRemoving unrelated changes and fixing tests.
Comment #38
mohrerao CreditAttribution: mohrerao as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedAdding fix for failed test in #36
Comment #39
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedFixed PHPLint issue in patch #38.
Comment #40
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedThe patch does not apply. Kindly review new patch.
Comment #41
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedKindly review a new patch.
Comment #42
mohrerao CreditAttribution: mohrerao as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedRerolled as #41 failed to apply
Comment #44
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedFixing test cases.
Comment #45
mondrakeThank you. This is a big patch. I would suggest splitting this issue in 3:
1) a first issue to remove the
$message
parameter from calls toassertRaw
andassertNoRaw
. This is already redundant as in the legacy trait these methods are defined asprotected function assertRaw($raw)
. Suggest following #3131946: [META] [policy] Remove PHPUnit assertion messages when possible, and standardize remaining messages for guidelines when a $message should be converted to an inline comment.2) a second issue to remove the calls to t() from calls to
assertRaw
, unless we are testing the translation layer.3) finally this one that at that point will be simply a find and replace exercise.
Comment #46
mondrakeFiled #3159230: AssertLegacyTrait::assert(No)Raw() in functional tests still have a message passed in.
Comment #47
mondrake#3159230: AssertLegacyTrait::assert(No)Raw() in functional tests still have a message passed in got in, but now we need to wait for #3170396: Remove uses of t() and switch to pageTextContains() in assert(No)Raw() calls.
Comment #50
mondrakeFIled #3227060: Replace usages of AssertLegacyTrait::assertNoRaw, that is deprecated to deal with assertNoRaw separately.
Comment #51
daffie CreditAttribution: daffie commented#3227060: Replace usages of AssertLegacyTrait::assertNoRaw, that is deprecated has landed.
Comment #52
mondrakeNow this needs a serious reroll… probably it will take less to start from scratch. Plus, we need to convert also looking at opportunity to use pageTextContains() or element*() methods instead of pure responseContains().
Comment #54
mondrakeRemoved deprecation silencer + added deprecation test.
Comment #55
mondrakeNote that Kernel tests should NOT be converted.
Comment #56
mondrakeworking on this
Comment #57
mondrakeFor review.
Comment #58
daffie CreditAttribution: daffie commentedThe deprecation message suppression has been removed.
All usage of
assertRaw()
has been replaced.For me it is RTBC.
Comment #59
catchCommitted/pushed to 9.3.x, thanks!
We should backport this to 9.2.x (without the deprecation suppression removal), but it needs a re-roll/rebase there.
Comment #62
paulocsComment #64
paulocsPlease review it.
Comment #65
catch@xjm pointed out that this appears to have introduced a random test failure, see https://www.drupal.org/pift-ci-job/2144401 and others.
Rolling back for now.
Comment #68
mondrakeWhen I made this conversion, I initially bulk changed
assertRaw()
withpageTextContains()
that is tighter thanresponseContains()
, then walked back and did manually change again toresponseContains()
where appropriate. Quite evidently, I missed some. Sorry for that.Comment #69
longwaveSwitching back to responseContains() means this is the same as the original code, so this should fix the random fail issue.
Comment #71
catchThis probably means the element we're looking for is sometimes visible, sometimes not - worth a follow-up if there isn't one already, however not the fault of this issue at all.
Back to 9.2.x for the backport again.
Comment #72
longwaveRerolled and force pushed the 9.2.x branch. Marking NR as there were a number of merge conflicts so would like a manual review to confirm.
Comment #73
Wim LeersFYI: this broke the https://www.drupal.org/project/ckeditor5 tests. It was frustrating to solve.
The solution?
Use
::responseContains()
instead of::pageTextContains()
.That's not what the issue title is saying, but … nonetheless this issue broke that. #68 implies as much. We should be warning module maintainers about this change.
I suspect this is only a problem for
::pageTextContains()
calls that were trying to assert the presence of strings in AJAX responses. Maybe that was not a technically correct usage of that assertion method, but it did work before. So chances are that more module maintainers are adversely affected by this.Can we please add a change record to warn module maintainers? 🙏
Updated CKEditor 5 tests in #3227531: Unbreak tests: Drupal core's #3139409 broke tests.
Comment #75
longwave@Wim Leers I am not sure how the conversions in this issue broke your tests. The change record at https://www.drupal.org/node/3129738 already says that
assertRaw()
should be converted toresponseContains()
. The deprecation notice on assertRaw() says the same thing:The difference with this issue is that instead of doing a 1:1 conversion,
assertRaw()
was often the wrong assertion when a test was really looking for page text and not raw HTML, and sopageTextContains()
was more appropriate.However, are you saying that if you revert the MR from this issue, your tests pass? ie. that we have broken an assertion in this issue that contrib previously relied on?
Comment #76
Wim LeersYes 🙈
Comment #77
mondrake@Wim Leers looking at your fix, I cannot see how this issue impacts. Here we changed assertRaw to either pageTextContains or responseContains, i.e. replaced legacy methods with recent ones. There you replaced pageTextContains with responseContains, but neither of these are touched here.
Maybe #3175718: Random fails due to drupal-settings-json being counted as page text is possibly the cause?
Comment #78
paulocsAny update?
Comment #79
mondrakeD9.2 patch looks good to me, changes are mainly due to not backported file_create_url calls. See diff of diffs attached.
Comment #80
longwaveBumping this as it is blocking backport of #3227501: [backport] Remove remaining uses of t() in test assertions
I don't think a change record is needed here, we already have https://www.drupal.org/node/3129738
Comment #81
catchNeeds another rebase.
I think it's just this: core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
Comment #82
paulocsComment #83
paulocsI only merged 9.2.x into 3139409-9.2.x but no conflicts were triggered.
Not sure if it needed to be rebased... I'm moving the issue to NR to get more feedbacks.
Comment #84
mondrakeComment #85
catchRebase was plenty. Committed/pushed to 9.2.x, thanks!