Problem/Motivation

AssertLegacyTrait::assertUrl() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Title: Replace usages of AssertLegacyTrait::, that is deprecated » Replace usages of AssertLegacyTrait::assertUrl, that is deprecated
jungle’s picture

Issue tags: +Deprecated assertions

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

mondrake’s picture

Status: Active » Needs review
FileSize
1.88 KB

Kick-off, just removing the silencer.

Status: Needs review » Needs work

The last submitted patch, 4: 3139419-4.patch, failed testing. View results

aleevas’s picture

Status: Needs work » Needs review
FileSize
135.21 KB

Added patch with replacements

Status: Needs review » Needs work

The last submitted patch, 6: 3139419-6.patch, failed testing. View results

aleevas’s picture

Status: Needs work » Needs review
FileSize
132.95 KB
2.86 KB

Fixed failed tests

mondrake’s picture

Assigned: Unassigned » mondrake
Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks! This needs a 'deprecation test', to show that if assertUrl is still called, then the deprecation error is triggered.

I am taking the issue to do that.

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests +Needs followup
FileSize
905 bytes
133.47 KB

Added a deprecation test.

+++ b/core/modules/comment/tests/src/Functional/Views/WizardTest.php
@@ -52,7 +52,7 @@ public function testCommentWizard() {
     $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
-    $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
+    $this->assertSession()->addressEquals('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
 
     // If we update the type first we should get a selection of comment valid

We still have calls to assertUrl that pass in the $message argument, even if that is stale already. In other issues we are postponing on those being removed, here at least we need a follow-up. Please do not remove or refactor those here, since latest direction is to just do the method call change in these issues.

mondrake’s picture

Status: Needs review » Postponed
Issue tags: -Needs followup

Actually, there is even an $option argument passed in, the empty array here in some cases, which is stale too. All in all, better postpone this one to an issue to cleanup the board.

mondrake’s picture

mondrake’s picture

Status: Postponed » Needs work
Issue tags: +Needs reroll

Parent issues were committed, we can work on this now.

mondrake’s picture

Assigned: Unassigned » mondrake

on this.

mondrake’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
123.79 KB
mondrake’s picture

Assigned: mondrake » Unassigned
jungle’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs reroll again :(

mondrake’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
123.8 KB
jungle’s picture

  1. $ git grep assertUrl\(
    core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php:    // $this->assertUrl('admin/structure/views');
    core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php:  protected function assertUrl($path) {
    core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php:    @trigger_error('AssertLegacyTrait::assertUrl() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
    core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php:      @trigger_error('Calling AssertLegacyTrait::assertUrl() with more than one argument is deprecated in drupal:8.2.0 and the method is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
    core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php:   * @expectedDeprecation AssertLegacyTrait::assertUrl() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738
    core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php:   * @expectedDeprecation Calling AssertLegacyTrait::assertUrl() with more than one argument is deprecated in drupal:8.2.0 and the method is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738
    core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php:    $this->assertUrl('bingo', 'Redundant message.');
    core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php:    $this->assertUrl($expected_route_name, ['test_entity' => $this->entityId], $entity, TRUE, $url);
    core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php:    $this->assertUrl($expected_route_name, $expected_route_parameters, $entity, TRUE, $url);
    core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php:    $this->assertUrl($expected_route_name, [], $entity, FALSE, $url);
    core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php:    $this->assertUrl('entity.test_entity.add_form', $expected_route_parameters, $entity, FALSE, $url);
    core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php:    $this->assertUrl('<none>', [], $entity, TRUE, $url);
    core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php:  protected function assertUrl($expected_route_name, array $expected_route_parameters, $entity, $has_language, Url $url) {
    
    
    $ git grep assertUrl\( | grep -v EntityUrlTest | grep -v AssertLegacyTrait
    core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php:    // $this->assertUrl('admin/structure/views');
    

    It's ok to keep the one usage in inline comment in DefaultViewsTest to me.

  2. +++ b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
    @@ -194,6 +194,7 @@ public function testAssertNoCacheTag() {
    +   * @expectedDeprecation AssertLegacyTrait::assertUrl() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738
    
    +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
    @@ -138,7 +138,6 @@ public static function getSkippedDeprecations() {
    -      'AssertLegacyTrait::assertUrl() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738',
    

    Tested and removed as expected

If no CS violations and the testing passes, it's RTBC to me. Cycling back later.

jungle’s picture

Status: Needs review » Reviewed & tested by the community

No CS violations and GREEN as expected. Thanks @mondrake!

catch’s picture

Status: Reviewed & tested by the community » Needs work

#19.1 I think we should actually update that here - either by changing the commented code, changing and uncommenting it, or removing it if the assertion is really not needed. Or if not add a follow-up to deal with the commented assertions in that test.

mondrake’s picture

Assigned: Unassigned » mondrake
mondrake’s picture

Assigned: mondrake » Unassigned
Status: Needs work » Reviewed & tested by the community
FileSize
124.21 KB
852 bytes

Rerolled, and re #19.1 just changed the commented code, since refactoring further seems to me OOS here. RTBC since it's only change to docs.

catch’s picture

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

Needs another re-roll..

mondrake’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
124.25 KB
1.43 KB

Reroll.

  • catch committed c09dc39 on 9.1.x
    Issue #3139419 by mondrake, aleevas: Replace usages of AssertLegacyTrait...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed c09dc39 and pushed to 9.1.x. Thanks!

alexpott’s picture

For some reason this is still in the rtbc queue so pressing save again...

Status: Fixed » Closed (fixed)

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