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.
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.
Comment | File | Size | Author |
---|---|---|---|
#19 | link_handling_should-855726-19-complete.patch | 5.48 KB | LoMo |
#18 | link_handling_should-855726-18-test-only.patch | 2.49 KB | LoMo |
#17 | link_handling_should-855726-17-complete.patch | 5.52 KB | LoMo |
#16 | link_handling_should-855726-16-test-only.patch | 2.49 KB | LoMo |
#15 | link_handling_should-855726-15.patch | 3.21 KB | LoMo |
Comments
Comment #1
boombatower CreditAttribution: boombatower commentedComment #2
thedavidmeister CreditAttribution: thedavidmeister commentedThis is still an issue in D8.
Patch no longer applies in D7.
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.
Comment #5
arunkumarkPatch no longer applies cleanly.
Comment #7
LoMo CreditAttribution: LoMo as a volunteer commentedRe #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.
Comment #9
LoMo CreditAttribution: LoMo as a volunteer commentedAh... 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.Comment #11
LoMo CreditAttribution: LoMo as a volunteer commentedOkay, this patch should apply against the 8.3.x-dev branch...
Comment #12
LoMo CreditAttribution: LoMo as a volunteer commentedComment #13
LoMo CreditAttribution: LoMo as a volunteer commentedAnd this patch should apply on the 8.4.x-dev branch...
Comment #15
LoMo CreditAttribution: LoMo as a volunteer commentedLet'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. ;-)
Comment #16
LoMo CreditAttribution: LoMo as a volunteer commentedThe new test should fail (against 8.4.x-dev)
Comment #17
LoMo CreditAttribution: LoMo as a volunteer commentedBut 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 theassertLink()
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".Comment #18
LoMo CreditAttribution: LoMo as a volunteer commentedAnd this test patch is for the 8.3.x branch. Tests should fail, but pass in a "complete" patch.
Comment #19
LoMo CreditAttribution: LoMo as a volunteer commentedThis is the combined patch that should apply and run without failures on the 8.3.x branch.
Comment #29
quietone CreditAttribution: quietone as a volunteer commentedTriaging 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.