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.
Problem/Motivation
In Drupal\Tests\WebAssert
, linkNotExists() and linkByHrefNotExists() default message are same as respectively linkExists() and linkByHrefExists().
public function linkNotExists($label, $message = '') {
$message = ($message ? $message : strtr('Link with label %label found.', ['%label' => $label]));
public function linkByHrefExists($href, $index = 0, $message = '') {
$xpath = $this->buildXPathQuery('//a[contains(@href, :href)]', [':href' => $href]);
$message = ($message ? $message : strtr('Link containing href %href found.', ['%href' => $href]));
It should be more explicit that string should not be found.
Comment | File | Size | Author |
---|---|---|---|
#26 | Default_message_for-2854249-26.patch | 795 bytes | saurabh rawat |
#18 | default_message_for-2854249-18.patch | 1.68 KB | GoZ |
#14 | 2854249-14.patch | 1.71 KB | himanshu-dixit |
#10 | default_message_for-2854249-10-test-only.patch | 2.39 KB | GoZ |
#3 | Screen Shot 2017-02-20 at 10.15.54 PM.png | 795.57 KB | boaloysius |
Comments
Comment #2
GoZ CreditAttribution: GoZ at Centarro commentedComment #3
boaloysius CreditAttribution: boaloysius as a volunteer commentedI applied the patch and here are the screenshots.
Comment #4
empesan CreditAttribution: empesan commentedPatch applied correctly in linkNotExists() and linkByHrefNotExists() functions
Comment #5
boaloysius CreditAttribution: boaloysius as a volunteer commentedCan we move the status to "Reviewed & tested by the community"
Comment #6
boaloysius CreditAttribution: boaloysius as a volunteer commentedComment #7
xjmOoh, this gets tricky and confusing for sure.
So maybe "No link with label %label"? (and ditto for the other for href)
(Out-of-scope side: strtr? Why on earth? Anyway.)
Hopefully that is not too much, but it would help prove the fix is correct.
Also IMO this isn't minor; it could actually screw up your debugging or test coverage because the message is essentially telling you what is the opposite of true. So promoting to normal.
Finally, can and should backport. While it is a "string" change it is no longer translated and we don't guarantee the translation of developer output.
Thanks and good find!
Comment #8
xjmAlso-too, we should compare to what the PHPUnit method that's being overridden said. Sorry that this is so many things to test for an essentially two-line patch. But this is an area where computers are much more reliable than our brains.
Comment #9
GoZ CreditAttribution: GoZ at Centarro commentedThose methods don't exist in PHPUnit. It's Drupal specific.
Comment #10
GoZ CreditAttribution: GoZ at Centarro commentedHere is tests to show what should fail.
Comment #12
GoZ CreditAttribution: GoZ at Centarro commentedFail as expected
Comment #13
xjm@GoZ, thanks!
There is nothing wrong with the snippet exactly; that's just unfortunately how Dreditor pastes it since it tries to guess what the start of the function is from the diff header. The point is the change to the assertion message I've requested. Sorry if the default Dreditor formatting distracted from that.
This specific method is Drupal-specific. However, it (and everything else in BTB/WebAssert and AssertLegacyTrait) leverage PHPUnit and its assertion functionality. But actually what I said had a typo; sorry for the confusion. What I meant was to compare with the previous messages from before PHPUnit and use that pattern, e.g.: https://api.drupal.org/api/drupal/modules%21simpletest%21drupal_web_test... (the D7 version).
#10 was quite a bit more than I meant (and I meant a test patch to demonstrate the patch on the issue), but it also proves the point just as well. So that is good. Thanks! The one other bit from #7 was making sure the also matched. I just confirmed that myself.
So, just NW now to actually update the message test to just add the word "not" in the correct places like https://api.drupal.org/api/drupal/modules%21simpletest%21drupal_web_test..., rather than the current message which is not quite grammatical.
Also @boaloysius, I didn't mention this before, but now I saw it on another issue you contributed to as well. Posting screenshots of code in your IDE isn't helpful really. We don't need you to prove that the patch applies; testbot does that for us. We can always just read the code ourselves with the patch applied, also. Screenshots are primarily useful when testing user-facing patches. What is helpful though is describing what you thought about when you reviewed the patch and what you tried.
Thanks!
Comment #14
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer commentedHere is the new patch. Sorry, i have not attached interdiff since this is a small patch.
Comment #16
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer commentedComment #17
krknth CreditAttribution: krknth as a volunteer and at Valuebound commented@himanshu : your patch doesn't work
Comment #18
GoZ CreditAttribution: GoZ at Centarro commentedComment #19
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer commented@krknth Sorry, i assigned it to myself to work on it later. It was because i manually edited the patch, i should have used git diff. @GoZ Thanks it looks good to me but since i also worked on this patch, it's better i don't RTBC it. Thanks for rerolling it. GoZ++
Comment #20
dhruveshdtripathi CreditAttribution: dhruveshdtripathi as a volunteer and at DevsAdda for OpenSense Labs commentedPatch applied successfully and seems OK
Comment #23
catchCommitted/pushed to 8.4.x and cherry-picked to 8.3.x. Thanks!
Comment #24
dhruveshdtripathi CreditAttribution: dhruveshdtripathi as a volunteer and at DevsAdda for OpenSense Labs commentedComment #25
xjmCorrecting issue credit. @boaloysius, please don't post any more screenshots of your codebase; they aren't needed. Thanks!
Comment #26
saurabh rawat CreditAttribution: saurabh rawat as a volunteer commentedComment #28
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer and at Google Summer of Code commentedAttributing the contribution to GSoC.