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.
Comment | File | Size | Author |
---|---|---|---|
#30 | 2735199-15.patch | 5.01 KB | Eric_A |
#17 | 2735199-15.patch | 5.01 KB | naveenvalecha |
Comments
Comment #2
klausiThis patch includes #2735045: Convert StandardTest to BrowserTestBase by introducing a AssertLegacyTrait and new assertions on the WebAssert.
Comment #3
jhodgdonI took a quick look at this patch. I have a few questions about the changes in the patch:
I noticed this line took out the t() call -- used to be t($name). Was that intentional? Have we lost something?
I don't understand why you took some of the custom messages out of assertions here, and not others. Also why that would be part of converting this to BrowserTestBase. That seems like a separate issue?
Comment #4
klausiTaking out the t() call: yes, that is intentional. Since I have to change the line anyway I can as well make it right. We are not testing translation here and t() is almost always wrong in test code. We want to assert the literal name on the page - it does not make sense to send it through t() beforehand.
Reverted the change of assertion messages to comments. Custom assertion messages are now ignored for some assertion methods because the mink web assert methods have no message parameters. I think that is ok because a clear assertion such as assertStatusCode() should say something about what was asserted - the status code of the response. Any additional explanations should live as code comments. Since PHP happily eats additional method arguments without raising errors those assertion messages now just vanish. So we should convert them to code comments I think, but that can also be done in a separate issue.
Attached is also a for_review.txt diff that was generated with
git diff origin/8.2.x -- core/modules/ > for_review.txt
to show only the changed for help.module and ignores the changes from #2735045: Convert StandardTest to BrowserTestBase by introducing a AssertLegacyTrait and new assertions on the WebAssert.Comment #6
jibranComment #7
dawehnerIMHO we should instead of reinventing those assertions rather add a
\Drupal\FunctionalTests\AssertLegacyTrait
which wraps the new available assertions and is marked as deprecated. This one could be$this->assertSession()->elementExists()
You know, we want to teach good practises rather than just continue with our drupalisms.
elementNotExists
pageTextContains
pageTextNotContains
statusCodeEquals
For this case where there is clearly no existing assertion, IMHO we should move the stuff to
\Drupal\Tests\WebAssert
Yeah this example here is pure legacy. You ideally don't want to have one function that does two different things.
In this case we should just leverage
\Drupal\KernelTests\AssertLegacyTrait
which has some of that stuff already.Can we move this also to a legacy function or would you personally keep that?
Nice
Comment #8
dawehnerFor
assertEqual
... we should move this toassertEquals
itself, as you have the same problem in new tests as well.Comment #9
dawehnerI agree, t($name) really doesn't help much unless you actually test locale functionality.
Comment #10
klausiMerged in the changes from #2735045: Convert StandardTest to BrowserTestBase by introducing a AssertLegacyTrait and new assertions on the WebAssert, this should address all of dawehner's comments.
Comment #11
jhodgdonThis looks OK to me. Most of the patch is from the other issue, of course... so I guess this needs to be postponed until that other one is done?
Comment #12
klausiExactly.
Comment #13
naveenvalechaunpostponing this one. Also this needs a reroll after this #2735045: Convert StandardTest to BrowserTestBase by introducing a AssertLegacyTrait and new assertions on the WebAssert
Comment #14
naveenvalechaComment #15
dawehnerSeems reasonable now.
Comment #16
alexpottComment #17
naveenvalechaRerolled after #2736109: Convert web tests to browser tests for action module
Comment #18
klausiLooks good, thanks!
Comment #19
alexpottCommitted 3991692 and pushed to 8.2.x. Thanks!
I'll cherry-pick to 8.1.x if tests pass there too.
Fixed on commit.
Comment #20
alexpottComment #22
klausiDoes not apply to 8.1.x, I guess we don't care and don't want to spend time on rerolling it.
Comment #23
anavarreWas this actually committed? The 3991692 object ID doesn't exist and I can't find anything in the git log.
Comment #25
klausiIt is pushed to 8.2.x, just the commit hash is a different one.
Comment #26
pfrenssenThe
assertNoEscaped()
method that is introduced here has the wrong visibility which causes a fatal error. I created a followup for this: #2752315: Fix visibility of AssertLegacyTrait::assertNoEscaped().Comment #27
Eric_A CreditAttribution: Eric_A commentedWe'll have a hard time porting these conversions since our recent failure to sync changes in AssertLegacyTrait, WebAssert, BrowserTestBase. The conversions are not important for 8.1.x, but the failure to sync AssertLegacyTrait, WebAssert, BrowserTestBase might come to hunt us later when cherry-picking other, not conversion related issues. Therefor I submitted a reroll for 8.1.x in #2736109-23: Convert web tests to browser tests for action module. That one turned out to be a very easy to fix conflict.
Comment #28
Eric_A CreditAttribution: Eric_A commentedNow that #2736109: Convert web tests to browser tests for action module is in 8.1.x, this one applies again for 8.1.x. Note that the coding standards fix that was applied on commit needs to be done for 8.1.x as well and also the follow-up #2752315: Fix visibility of AssertLegacyTrait::assertNoEscaped(). Two standard cherry-picks suffice.
It would be good to have AssertLegacyTrait the same in all branches. (And the help tests.)
I tried to requeue against 8.1.x but the bot started testing against 8.2.x. Guess I'll re-upload after the 8.2.x test fails.
Comment #30
Eric_A CreditAttribution: Eric_A commentedRe-uploaded 2735199-15.patch from #17.
When this is green we can simply cherry-pick a142151. (And then 58c3b96 from #2752315: Fix visibility of AssertLegacyTrait::assertNoEscaped())
Comment #32
Eric_A CreditAttribution: Eric_A commentedUnrelated fails in Drupal\field\Tests\Update\FieldUpdateTest. (https://www.drupal.org/pift-ci-job/343553).
Back to RTBC as per #18/ #28.
We'll get fully synced AssertLegacyTrait and help tests if we cherry-pick a142151 here followed by 58c3b96 from #2752315: Fix visibility of AssertLegacyTrait::assertNoEscaped().
Comment #33
dawehnerThis looks also great for me!
Comment #34
alexpottCommitted 792d444 and pushed to 8.1.x. Thanks!