Problem/Motivation
This is a result of comments made by Kristen Pol in a review of #3200534: Use dataprovider for constructor test in ContentEntityTest mostly related to adding comments. However, one comment pointed out that it wasn't clear why the anonymous user was created. And even worse, the tests still pass when removing anonymous and it should not.
Steps to reproduce
Proposed resolution
Add comments as per #3200534-8: Use dataprovider for constructor test in ContentEntityTest
Add an assertion that the anonymous user exists in testUser.
Remaining tasks
Review
Commit
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3229734-6.patch | 2.02 KB | quietone |
| #6 | interdiff-2-6.txt | 1.31 KB | quietone |
| #2 | 3229734-2.patch | 2.1 KB | quietone |
| #2 | 3229734-2-fail.patch | 1.99 KB | quietone |
Comments
Comment #2
quietone commentedHere is a patch and a fail patch that shows that the anonymous user is needed.
Comment #3
quietone commentedComment #5
danflanagan8Is there a reason that the above would be prefered over something like this:
$this->assertNotNull(User::load(0), 'There is not an anonymous user.');I would rather see a single line if there's not some subtlety I'm missing.
Comment #6
quietone commented@danflanagan8, thanks!
#5. Sure, one line is nicer. And I merged the two comments into one because I thought it read better.
Comment #7
danflanagan8I agree that the updated comment is much clearer. This looks good to me.
Edit: For the record, I confirmed that the one-line assertion fails when the anonymous user is not created in
setUp. I suppose we could update the fail patch with the one-line assertion and run it on d.o. I did that locally though and it went as expected.Comment #9
danflanagan8That's an unrelated random test failure. Looks like #3099427: [random test failure] FieldLayoutTest::testEntityView(). Resetting to RTBC.
Comment #11
alexpottCrediting @Kristen Pol since many of these changes are due to a comment on the other issue.
Committed and pushed 0bed3aeeef to 9.3.x and 67a30ac667 to 9.2.x. Thanks!
Backported to 9.2.x as these are test-only changes.