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

CommentFileSizeAuthor
#79 diff.txt22.48 KBmondrake
#2 3139409-2.patch2.12 KBmondrake
#7 3139409-test-case-only-7.patch546.45 KBshobhit_juyal
#9 3139409-test-only-8.patch533.4 KBshobhit_juyal
#11 Screenshot 2020-05-28 at 9.58.15 PM.png2.82 MBmohrerao
#13 3139409-8-failed.png87.93 KBnitesh624
#13 3139409-13.patch576.07 KBnitesh624
#14 3139409-14.patch576.07 KBnitesh624
#15 3139409-15.patch548.68 KBnitesh624
#16 interdiff_14-15.txt22.28 KBnitesh624
#18 patch-15-does-not-applying.png40.58 KBshobhit_juyal
#20 3139409-20.patch548.03 KBnitesh624
#24 3139409-24.patch544.31 KBshobhit_juyal
#24 interdiff_20-24.txt9.18 KBshobhit_juyal
#27 3139409-27.patch544.3 KBmunish.kumar
#27 interdiff-24-27.txt1.28 KBmunish.kumar
#31 3139409-31.patch546.84 KBmrinalini9
#34 3139409-34.patch654.83 KBridhimaabrol24
#34 interdiff_31-34.txt35.91 KBridhimaabrol24
#36 3139409-36.patch622.48 KBridhimaabrol24
#36 interdiff_34-36.txt26.66 KBridhimaabrol24
#38 3139409-38.patch622.48 KBmohrerao
#38 interdiff_36-38.txt729 bytesmohrerao
#39 3139409-39.patch622.48 KBravi.shankar
#39 interdiff_38-39.txt803 bytesravi.shankar
#40 3139409-40.patch622.36 KBHardik_Patel_12
#40 interdiff-39-40.txt49.69 KBHardik_Patel_12
#41 3139409-41.patch622.35 KBHardik_Patel_12
#41 interdiff-40-41.txt869 bytesHardik_Patel_12
#42 3139409_reroll-42.patch622.72 KBmohrerao
#44 3139409-44.patch623.99 KBridhimaabrol24
#44 interdiff_42-44.txt1.51 KBridhimaabrol24

Issue fork drupal-3139409

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

mondrake’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 3139409-2.patch, failed testing. View results

jungle’s picture

Issue tags: +Deprecated assertions

Adding the "Deprecated assertions" tag to add this into the kanban board https://contribkanban.com/board/Deprecatedassertions

shobhit_juyal’s picture

Assigned: Unassigned » shobhit_juyal
shobhit_juyal’s picture

Assigned: shobhit_juyal » Unassigned
Status: Needs work » Needs review
FileSize
546.45 KB

I have added the patch which only includes test case fixes in #2.
Needs Review

Status: Needs review » Needs work

The last submitted patch, 7: 3139409-test-case-only-7.patch, failed testing. View results

shobhit_juyal’s picture

Previous patch has some issue, uploaded new patch

shobhit_juyal’s picture

Status: Needs work » Needs review

Tests passed, moving the ticket for review.

mohrerao’s picture

Status: Needs review » Needs work
FileSize
2.82 MB

I can still see many instances of assertRaw in core.
assert raw occurances

nitesh624’s picture

Assigned: Unassigned » nitesh624
nitesh624’s picture

Replace remaining of assertRaw() as addressed in #11.
also can't create interdiff as patch in #8 needs reroll. see below screenshot3139409-8-failed

nitesh624’s picture

nitesh624’s picture

Re 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

nitesh624’s picture

FileSize
22.28 KB
nitesh624’s picture

Assigned: nitesh624 » Unassigned
Status: Needs work » Needs review
shobhit_juyal’s picture

Status: Needs review » Needs work
FileSize
40.58 KB

Hi, its strange why the patch is not applying...
@nitesh624, please see the snapshot

nitesh624’s picture

hi @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

nitesh624’s picture

Rerolled the patch #15

nitesh624’s picture

Assigned: Unassigned » nitesh624
nitesh624’s picture

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Needs work

Patch no longer applies.

shobhit_juyal’s picture

Status: Needs work » Needs review
FileSize
544.31 KB
9.18 KB

Needs review.

shobhit_juyal’s picture

Assigned: nitesh624 » Unassigned
nitesh624’s picture

RTBC +1

munish.kumar’s picture

Hi @shobhit_juyal, The latest patch has one coding standard issue, So I have fixed this here is the patch and the interdiff.

mohrerao’s picture

Status: Needs review » Reviewed & tested by the community

3139409-27.patch looks good. RTBC again

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The patch does not apply.

Also we need to remove

      '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',
      'AssertLegacyTrait::assertNoRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() instead. See https://www.drupal.org/node/3129738',

From \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations()

mrinalini9’s picture

Assigned: Unassigned » mrinalini9
mrinalini9’s picture

Assigned: mrinalini9 » Unassigned
Status: Needs work » Needs review
FileSize
546.84 KB

Rerolled patch #27 and also done changes as mentioned in #29, please review.

Status: Needs review » Needs work

The last submitted patch, 31: 3139409-31.patch, failed testing. View results

ridhimaabrol24’s picture

Assigned: Unassigned » ridhimaabrol24
ridhimaabrol24’s picture

Assigned: ridhimaabrol24 » Unassigned
Status: Needs work » Needs review
FileSize
654.83 KB
35.91 KB

Trying to fix failed test cases in #31.
Replaced assertnoraw() deprecated function.

Status: Needs review » Needs work

The last submitted patch, 34: 3139409-34.patch, failed testing. View results

ridhimaabrol24’s picture

Status: Needs work » Needs review
FileSize
622.48 KB
26.66 KB

Removing unrelated changes and fixing tests.

Status: Needs review » Needs work

The last submitted patch, 36: 3139409-36.patch, failed testing. View results

mohrerao’s picture

Adding fix for failed test in #36

ravi.shankar’s picture

Status: Needs work » Needs review
FileSize
622.48 KB
803 bytes

Fixed PHPLint issue in patch #38.

Hardik_Patel_12’s picture

FileSize
622.36 KB
49.69 KB

The patch does not apply. Kindly review new patch.

Hardik_Patel_12’s picture

Kindly review a new patch.

mohrerao’s picture

Rerolled as #41 failed to apply

Status: Needs review » Needs work

The last submitted patch, 42: 3139409_reroll-42.patch, failed testing. View results

ridhimaabrol24’s picture

Status: Needs work » Needs review
FileSize
623.99 KB
1.51 KB

Fixing test cases.

mondrake’s picture

Title: Replace usages of AssertLegacyTrait::assert(No)Raw, that is deprecated » [PP-2] Replace usages of AssertLegacyTrait::assert(No)Raw, that is deprecated
Status: Needs review » Postponed

Thank 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 to assertRaw and assertNoRaw. This is already redundant as in the legacy trait these methods are defined as protected 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.

mondrake’s picture

mondrake’s picture

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mondrake’s picture

Title: [PP-1] Replace usages of AssertLegacyTrait::assert(No)Raw, that is deprecated » [PP-1] Replace usages of AssertLegacyTrait::assertRaw, that is deprecated
daffie’s picture

Title: [PP-1] Replace usages of AssertLegacyTrait::assertRaw, that is deprecated » Replace usages of AssertLegacyTrait::assertRaw, that is deprecated
Status: Postponed » Needs work
mondrake’s picture

Issue tags: +Needs reroll

Now 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().

mondrake’s picture

Removed deprecation silencer + added deprecation test.

mondrake’s picture

Note that Kernel tests should NOT be converted.

mondrake’s picture

Assigned: Unassigned » mondrake

working on this

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll

For review.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

The deprecation message suppression has been removed.
All usage of assertRaw() has been replaced.
For me it is RTBC.

catch’s picture

Title: Replace usages of AssertLegacyTrait::assertRaw, that is deprecated » [backport] Replace usages of AssertLegacyTrait::assertRaw, that is deprecated
Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Committed/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.

  • catch committed 71e8db1 on 9.3.x
    Issue #3139409 by mondrake, nitesh624, ridhimaabrol24, shobhit_juyal,...

paulocs’s picture

Assigned: Unassigned » paulocs

paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll

Please review it.

catch’s picture

Title: [backport] Replace usages of AssertLegacyTrait::assertRaw, that is deprecated » Replace usages of AssertLegacyTrait::assertRaw, that is deprecated
Version: 9.2.x-dev » 9.3.x-dev
Status: Needs review » Needs work

@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.

  • catch committed 604fee3 on 9.3.x
    Revert "Issue #3139409 by mondrake, nitesh624, ridhimaabrol24,...

mondrake’s picture

Status: Needs work » Needs review

When I made this conversion, I initially bulk changed assertRaw() with pageTextContains() that is tighter than responseContains(), then walked back and did manually change again to responseContains() where appropriate. Quite evidently, I missed some. Sorry for that.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Switching back to responseContains() means this is the same as the original code, so this should fix the random fail issue.

  • catch committed 7af1ea2 on 9.3.x
    Issue #3139409 by mondrake, nitesh624, ridhimaabrol24, shobhit_juyal,...
catch’s picture

Title: Replace usages of AssertLegacyTrait::assertRaw, that is deprecated » [backport] Replace usages of AssertLegacyTrait::assertRaw, that is deprecated
Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Needs work

This 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.

longwave’s picture

Status: Needs work » Needs review

Rerolled 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.

Wim Leers’s picture

FYI: 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.

longwave’s picture

@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 to responseContains(). The deprecation notice on assertRaw() says the same thing:

    @trigger_error('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', E_USER_DEPRECATED);

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 so pageTextContains() 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?

Wim Leers’s picture

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?

Yes 🙈

mondrake’s picture

@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?

paulocs’s picture

Any update?

mondrake’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
22.48 KB

D9.2 patch looks good to me, changes are mainly due to not backported file_create_url calls. See diff of diffs attached.

longwave’s picture

Issue tags: -Needs change record

Bumping 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

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Needs another rebase.

I think it's just this: core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll

I 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.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community
catch’s picture

Title: [backport] Replace usages of AssertLegacyTrait::assertRaw, that is deprecated » Replace usages of AssertLegacyTrait::assertRaw, that is deprecated
Status: Reviewed & tested by the community » Fixed

Rebase was plenty. Committed/pushed to 9.2.x, thanks!

  • catch committed bbf3dca on 9.2.x
    Issue #3139409 by mondrake, nitesh624, ridhimaabrol24, shobhit_juyal,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.