As I have come to find while writing tests many themes can screw up the testing framework with < span > tags and what not inside the < a > tag. This can be solved by looking for the text directly inside the link element or nested within.

The following will look the same in the browser.

<a>foobar<a>
<a><span>foobar</span></a>

But only the first will work with the assertLink(), assertNoLink(), and clickLink() methods.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boombatower’s picture

Assigned: Unassigned » boombatower
Status: Active » Needs review
FileSize
2.14 KB
thedavidmeister’s picture

Version: 7.x-dev » 8.x-dev
Assigned: boombatower » Unassigned
Status: Needs review » Needs work
Issue tags: +Needs tests

This is still an issue in D8.

Patch no longer applies in D7.

curl -0 https://drupal.org/files/issues/855726-nested-text.patch | git apply
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2189  100  2189    0     0   1815      0  0:00:01  0:00:01 --:--:--  2229
error: simpletest/drupal_web_test_case.php: No such file or directory

I feel like this XPath expression that assertLink(), assertNoLink() and clickLink() are all sharing could be centralised rather than duplicating it, but that might be out of scope for this issue.

Could we write tests for this? Assert links in some strings that we know should work but don't because of this bug?

#2094585: [policy, no patch] Core review bonus for #2072647: #theme 'maintenance_page' should support render arrays in #content.

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.

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

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

arunkumark’s picture

Issue summary: View changes

Patch no longer applies cleanly.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

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

LoMo’s picture

Status: Needs work » Needs review
FileSize
3.21 KB

Re #5; no, indeed, it does not apply at all. The pattern still exists, but is spread around pretty well. Let's try a re-roll and see if it breaks anything... Then maybe some tests. ;-)

I actually made these changes on my 8.4.x-dev local checkout, but I think it should also apply to 8.3.x; I'll leave the version on 8.3.x-dev to verify that, too.

Status: Needs review » Needs work

The last submitted patch, 7: link_handling_should-855726-7.patch, failed testing.

LoMo’s picture

Version: 8.3.x-dev » 8.4.x-dev
Status: Needs work » Needs review
FileSize
3.88 KB

Ah... found one more since the clickLink() function in WebTestBase changed significantly, but still used the original pattern. And it seems that this doesn't apply on the 8.3.x branch, so I would need to re-roll it slightly differently if it were to be applied there.

Status: Needs review » Needs work

The last submitted patch, 9: link_handling_should-855726-9.patch, failed testing.

LoMo’s picture

Okay, this patch should apply against the 8.3.x-dev branch...

LoMo’s picture

Status: Needs work » Needs review
LoMo’s picture

And this patch should apply on the 8.4.x-dev branch...

Status: Needs review » Needs work

The last submitted patch, 13: link_handling_should-855726-13.patch, failed testing.

LoMo’s picture

Status: Needs work » Needs review
FileSize
3.21 KB

Let's try that again... This is the 8.4.x version. The version for 8.3.x (#11) already passes all tests, so at least doesn't break anything. ;-)

LoMo’s picture

The new test should fail (against 8.4.x-dev)

LoMo’s picture

But it should pass with this patch (adapted from original pattern, since that did not seem to work). Actually, the pattern used in the clickLink() function turned out to work, while the pattern in the assertLink() did not, so I changed all instances to the pattern used by "clickLink(), which happens to be much simpler, but seems to catch all links by label quite well".

LoMo’s picture

And this test patch is for the 8.3.x branch. Tests should fail, but pass in a "complete" patch.

LoMo’s picture

This is the combined patch that should apply and run without failures on the 8.3.x branch.

The last submitted patch, 16: link_handling_should-855726-16-test-only.patch, failed testing.

The last submitted patch, 17: link_handling_should-855726-17-complete.patch, failed testing.

The last submitted patch, 18: link_handling_should-855726-18-test-only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 19: link_handling_should-855726-19-complete.patch, failed testing.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

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

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

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

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

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

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

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

quietone’s picture

Component: simpletest.module » phpunit

Triaging issues in simpletest.module as part of the Bug Smash Initiative to determine if they should be in the Simpletest Project or core.

This looks like it a Phpunit issue, changing component.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.