Follow-up to #2567851: Use assertText() instead of t()/SafeMarkup::format() in NodeEditFormTest

Problem/Motivation

NodeEditFormTest::testNodeEdit() sets $link_text but uses it only once:

    $link_text = 'Edit<span class="visually-hidden">(active tab)</span>';
    // @todo Ideally assertLink would support HTML, but it doesn't.
    $this->assertRaw($link_text, 'Edit tab found and marked active.');

Proposed Solution

Eliminate the temporary variable $link_text.

Comments

cilefen created an issue. See original summary.

anavarre’s picture

Status: Active » Needs review
StatusFileSize
new970 bytes
cilefen’s picture

@anavarre The work is, as usual, very good.

+++ b/core/modules/node/src/Tests/NodeEditFormTest.php
@@ -78,9 +78,8 @@ public function testNodeEdit() {
     // Check that the title and body fields are displayed with the correct values.
     // As you see the expected link text has no HTML, but we are using
-    $link_text = 'Edit<span class="visually-hidden">(active tab)</span>';
     // @todo Ideally assertLink would support HTML, but it doesn't.

These comments don't make sense as written with the code change in this patch.

I asked about it on the parent issue: #2567851-15: Use assertText() instead of t()/SafeMarkup::format() in NodeEditFormTest

rashid_786’s picture

StatusFileSize
new925 bytes
new1.05 KB

updated patch by removing unnecessary comments.

Status: Needs review » Needs work

The last submitted patch, 4: 2568287-4.patch, failed testing.

dawehner’s picture

  1. +++ b/core/modules/node/src/Tests/NodeEditFormTest.php
    @@ -76,11 +76,7 @@ public function testNodeEdit() {
    -    // Check that the title and body fields are displayed with the correct values.
    -    // As you see the expected link text has no HTML, but we are using
    

    So this is lost information ... no reason to kill it

  2. +++ b/core/modules/node/src/Tests/NodeEditFormTest.php
    @@ -76,11 +76,7 @@ public function testNodeEdit() {
    -    // @todo Ideally assertLink would support HTML, but it doesn't.
    

    That todo is still perfectly valid

latikas’s picture

Status: Needs work » Needs review
StatusFileSize
new956 bytes
new956 bytes

Re-rolled #6

cilefen’s picture

Status: Needs review » Needs work

#6 Simply removes the comments. This is not what is wanted. Let's go back to #2, and rework the comments so they make sense.

latikas’s picture

Status: Needs work » Needs review
StatusFileSize
new849 bytes
new849 bytes

The last submitted patch, 9: interdiff-6.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: 2568287-6.patch, failed testing.

The last submitted patch, 9: interdiff-6.patch, failed testing.

The last submitted patch, 9: 2568287-6.patch, failed testing.

miteshmap’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

updated comment and code.

dawehner’s picture

Status: Needs review » Needs work
cilefen’s picture

The challenge is to keep the essence and meaning of the comments in HEAD but fit them to the code change so they make sense.

drnikki’s picture

StatusFileSize
new1.02 KB

Try this one. Just kept the initial comment in HEAD and updated the code.

drnikki’s picture

Status: Needs work » Needs review

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mile23’s picture

Priority: Normal » Minor
Status: Needs review » Reviewed & tested by the community

This is a test improvement so 8.1.x seems to be an appropriate target.

The patch applies and removes an incoherent inline comment. It also removes the local variable $link_text by inlining the string. The string is the same.

Applies to both 8.1.x and 8.2.x.

Looks good to me.

  • catch committed ff28f52 on 8.2.x
    Issue #2568287 by latikas, rashid_786, drnikki, anavarre, miteshmap,...

  • catch committed 5775e3a on 8.1.x
    Issue #2568287 by latikas, rashid_786, drnikki, anavarre, miteshmap,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!

Status: Fixed » Closed (fixed)

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