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.
Discussed in #2867154: Form: Convert system functional tests to phpunit.
\Drupal\Tests\BrowserTestBase::drupalPostForm doesn't return the HTML of the rendered page.
From a BC perspective and for ease of conversion this method should probably have the same return value as \Drupal\simpletest\WebTestBase::drupalPostForm
Comment | File | Size | Author |
---|---|---|---|
#20 | interdiff-17-20.txt | 881 bytes | Anonymous (not verified) |
#20 | 2900292-20.patch | 2.35 KB | Anonymous (not verified) |
#17 | interdiff-15-17.txt | 1.07 KB | Anonymous (not verified) |
#17 | 2900292-17.patch | 2.26 KB | Anonymous (not verified) |
#15 | interdiff-12-15.txt | 1.93 KB | Anonymous (not verified) |
Comments
Comment #2
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation commentedSo... something like this?
Comment #3
Lendude@Manuel Garcia yeah that looks good, one nit:
'The HTML of the rendered page.' needs to be on the next line.
Comment #4
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commented@Lendude this patch contains 'The HTML of the rendered page.' on the next line . is it correct ?
Comment #5
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commentedComment #6
Anonymous (not verified) CreditAttribution: Anonymous commented#5: Almost, but seems, that #3 should be interpreted literally. Few examples from other places:
It may also be useful to formally fix this change via test.
Comment #7
Lendude#6++
Yes, added test coverage is great.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commented@Lendude, thank you!
We can also slightly improve the test, if check which line is returned.
Now we need to unite #2, #3 and current test (if @Lendude agrees that this variant is preferable).
@Meenakshi Gupta, do you still have the desire to help?
Comment #10
Lendude@vaplas Yeah #8 looks good as a test, it's what we expect right? Not just any string but that specific string.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedYes. You read my mind like an open book.
Comment #12
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedCombined patch from #2, #3, #8.
Comment #13
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedupdating status.
Comment #14
dawehnerShould we document here that the recommended way is to use $this->getSession()->getPage()->getContent() or actually the assertions we provide via the
webAssert
?Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commented#12: thank you, @shashikant_chauhan! All novice tasks are addressed, so remove the Novice tag.
#14: if I correctly understood the question, then the main reason is not in the recommendation to use the return value, but only in compatibility (especially for outside test, because to change the core tests - not a big deel). I tried to add a comment about it.
Also I adjusted the description a little, so that there would be no association with the html-format of the pages + tests:
Comment #16
dawehnerWhat do you think about moving the hint to webAssert into the function documentation itself? This would help a bit in terms of discovery, as people will most likely read the function documentation instead of the actual code of the function.
This
@see
feels a little bit weird ... I would have probably skipped that :)Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commented#16 I thought about this while I waited for the review. And I am absolutely glad about these proposals!
Comment #18
dawehnerThank you!
Comment #19
catchAre we going to want to deprecate the return for 9.0.x or just leave it like this?
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedThe
'(deprecated)'
mark definitely should help the wavering user, and will allow to eliminate the confusing variety in the future.Comment #21
LendudeHmm interesting deprecation case. Hadn't seen the return type deprecation before.
Per deprecation policy for this, we need a CR and a link to that CR for this.
Comment #22
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation commentedThanks all for the work on this!
I've added a draft CR, please review =) https://www.drupal.org/node/2907815
Comment #23
dawehnerThank you @Manuel Garcia to create the change record. I fixed a tiny bit of it, but it looks good for me.
Comment #26
catchYes return deprecation is hard.
Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!
Comment #28
Anonymous (not verified) CreditAttribution: Anonymous commentedShouldn't t('Submit') replaced with $this->t('Submit'); ??
Comment #29
Lendude@JohnOku that's not needed inside a test.
Comment #30
quietone CreditAttribution: quietone at PreviousNext commentedpublish the change record