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.
See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)
Conversion scope
All except: #2887869: Convert web tests to browser tests for user module part-2
- UserAdminSettingsFormTest
- UserPasswordResetTest
- UserBlocksTest
- UserRegistrationTest
- UserAdminLanguageTest
- UserCreateTest
- RestRegisterUserTest #2889882: Convert ResponseGeneratorTest, DbLogResourceTest, RestRegisterUserTest to BTB
Comment | File | Size | Author |
---|---|---|---|
#41 | interdiff-36-40.txt | 1.42 KB | Anonymous (not verified) |
#39 | d84-2870465-36.patch | 31.2 KB | Anonymous (not verified) |
#36 | interdiff-34-36.txt | 699 bytes | Anonymous (not verified) |
#36 | 2870465-36.patch | 32.31 KB | Anonymous (not verified) |
#31 | 2870465-31.patch | 32.38 KB | Lendude |
Comments
Comment #2
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #3
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #4
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedDropping a few dependencies and moving these tests out of scope. Keeping views because of the large amount of views tests.
Comment #5
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #6
naveenvalechaHere's the straight conversion. Let's see how many breaks. expecting Rest and views tests failures.
//Naveen
Comment #8
naveenvalechaRemoving
1) UserRegistrationTest as some part of it should be Javascript test
2) UserBlocksTest It should be postponed on some follow-up issue which converts the setRawContent b/c it's not available in BTB yet.
//Naveen
Comment #10
naveenvalechaHere are the fixes of the failures.
//Naveen
Comment #11
naveenvalechaAdded followup issue link
Comment #13
naveenvalechaAddressed #10 failures.
Comment #14
LendudeActually setRawContent means it needs to be converted to a kernel test, and since it's only a little bit of test we might do it in this issue (although the patch is big enough as it is, so I'm fine doing it in the followup too)
Comment #15
naveenvalechaI wouldn't mind doing it here if it blocks you to RTBC it?
//Naveen
Comment #16
Lendude#15 I'm fine with it being converted in the follow up.
And really nice to see one of the big modules taking a big step towards conversion!
some things I see:
\Drupal\Tests\user\Functional\RestRegisterUserTest
in extending a WebTestBase base class, it needs to extend\Drupal\Tests\rest\Functional\ResourceTestBase
constructFieldXpath is coming back in #2868019: AssertLegacyTrait field assertions not compatible with Simpletest assertions, maybe worth waiting on that. That only needs a little push to take it over the line, and it's used quite a lot here.
Why doesn't assertFieldById work here?
haha! nice cleanup.
Is this needed to make this pass? Otherwise lets keep this as one-on-one as we can
Comment #17
naveenvalecha#16.1 Filed a follow-up for this to discuss this in rest queue #2889399: Remove RestRegisterUserTest? Waiting for it if not will convert if it's really required.
#16.2 we could postpone it on that issue. We're blocking the whole conversion on a single item.How about removing this test out of the scope?
#16.3
AssertLegacyTrait::assertFieldById compares the value of the checkbox using
getvalue()
which would always be false either its checked or not checked.$this->assertEquals($value, $field->getValue());
As per the documentation of
\Behat\Mink\Element::getValue()
, For checkbox fields, the value is a boolean indicating whether the checkbox is checked but it didn't work. See the code below for reference.#16.4 :)
#16.5 yup it was required to make the tests pass.
P.S: I have not updated the issue status, please change it accordingly.
//Naveen
Comment #18
naveenvalecha#16.1
We required this test coverage as per the discussion in the #2889399: Remove RestRegisterUserTest? Created a followup issue so that we could convert all RestTestbase tests in the single go. #2889882: Convert ResponseGeneratorTest, DbLogResourceTest, RestRegisterUserTest to BTB
Updated IS to also remove RestRegisterUserTest from this patch in favor of #2889882: Convert ResponseGeneratorTest, DbLogResourceTest, RestRegisterUserTest to BTB
Back to N/R
//Naveen
Comment #19
naveenvalechaRemoved the UserAdminLanguageTest and UserCreateTest as they require the #2868019: AssertLegacyTrait field assertions not compatible with Simpletest assertions and doing it in follow-up as per word with @lendude over IRC. Let's convert the tests here which has minimum disruptions.
Also updated IS of #2887869: Convert web tests to browser tests for user module part-2
//Naveen
Comment #20
LendudeLooks great. We have a follow up for the remaining tests.
Comment #21
Gábor HojtsyWe don't use the mail method as drupalGetMails() but we do so for drupalGetTestFiles() we do. Why?
Why are these changes needed to convert the test? (And there are a lot more of them).
Comment #22
Lendude21.1 Yeah makes sense to al least make the them use the same pattern, don't really care which one, with or without the drupal prefix
21.2
\Drupal\Tests\BrowserTestBase::drupalLogin
vs\Drupal\simpletest\WebTestBase::drupalLogin
, BrowserTestBase uses passRaw, I assume so that the new testbase follows Drupal naming conventions for class properties (which pass_raw doesn't do)Comment #24
jofitz CreditAttribution: jofitz at ComputerMinds commentedAddressed comments in #21/#22:
Comment #26
nlisgo CreditAttribution: nlisgo commentedComment #27
nlisgo CreditAttribution: nlisgo commentedComment #28
LendudeComment #29
LendudeBleh, comment got eaten.
Needed a reroll, and improved the failing test, didn't look into why that started failing now.
Comment #31
LendudeHow did this come back green before?
Oh well, fixed fails.
Comment #32
Anonymous (not verified) CreditAttribution: Anonymous commentedLooks nice! All changes seem very certain, except few nits:
Looks like we can reduce different with orignal implementation. Example:
Similarly, save one-line, like:
Nit: pass_raw still in comments. Fixed :)
And this is the most suspicious change in my patch). It all started with the fact that I accidentally noticed that the testUserCancelUid1 green, although it still has
$user1->pass_raw = $password;
instead ofpassRaw
.Suspicions intensified, after the question from @xjm in #2322195-157: Replace all instances of user_load(), user_load_multiple(), entity_load('user') and entity_load_multiple('user') with static method calls:
After removed lines with
resetCache()
test still green.An expanded question appeared: why do we have to do something with user 1 (set a password, log in)? I did not find the answer and removed all the related code :) But if it goes beyond the scope, I will not argue.
Comment #33
Lendude@vaplas nice clean up.
I think this is almost ready, but lets not do #32.4, that seems way out of scope since we aren't even converting that test.
Comment #34
Anonymous (not verified) CreditAttribution: Anonymous commentedHah, I did not even notice that it was no longer a simpletest. Because just finding other cases with 'pass_raw'. Reverted and filed #2926090: Remove dead code from UserCancelTest::testUserCancelUid1().
Comment #35
Lendudebump
Comment #36
Anonymous (not verified) CreditAttribution: Anonymous commentedNit clean up after #34.
Comment #37
LendudeAll feedback has been addressed, we have a followup for the remaining tests, back to RTBC
Comment #38
catchCommitted 6648bb6 and pushed to 8.5.x. Thanks!
Comment #39
Anonymous (not verified) CreditAttribution: Anonymous commented#38: Bad object id: 6648bb6 :(
Also i checked 8.4 branch, and this patch needs to reroll, because UserPermissionsTest::testAccessContentPermission() added only for 8.5.x (#2892821: Core modules check node module's "access content" permission for displaying things that have nothing to do with nodes). Done.
Comment #40
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #41
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #43
dawehnera) I don't we need to commit it to 8.4.x
b) Catch pushed it nows, so I think we are fine
Comment #44
Anonymous (not verified) CreditAttribution: Anonymous commentedI just thought that additional synchronization between the branches would not hurt. But only for 8.5 - works for me too. Thanks!
Comment #45
dawehner@vaplas
For me its like: By default don't backport it, unless there is a good reason. Bugfixes for example might have a good reason.
Comment #46
Lendude@dawehner I think it would be nice if this did get a backport. All the other conversions have been backported and its nice to keep the testsuite in sync. This minimises the chances of having to rewrite tests for bugfixes to apply to 8.5.x and 8.4.x
Strictly speaking this is a test-only change so its eligible for backport, but it could be called disruptive so it might be ineligible because of that.... *shrug*
Comment #47
dawehnerYeah there is the advantage that backporting bugfixes for the user module becomes potentially easier with this.