Closed (fixed)
Project:
Drupal core
Version:
main
Component:
phpunit
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Aug 2026 at 09:32 UTC
Updated:
8 Sep 2026 at 19:50 UTC
Jump to comment: Most recent
HelpTest and HelpTopicTest both contain the following $anyUser property:
/**
* The anonymous user that will be created.
*
* @var \Drupal\user\Entity\User|false
*/
protected $anyUser;
But this user is not and never was anonymous. The docblock was written incorrectly three years after the property's addition. See the Git archaeology in comment #6.
@var annotations in the HelpTest and convert them to type hints (#7).Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
charlliequadros commentedHi @joachim
When it sets the current user, there is a comment saying // Log in the regular user.. This indicates that the test checks whether a regular user receives a 403 error when trying to access pages they do not have permission to access. So I updated the comments to make the test's intent clearer.
Comment #5
charlliequadros commentedComment #6
dcam commentedI was able to perform some successful Git archaeology on this property. The original
$any_userproperty was added to the Help simpletest by Dries back in 2008. Aside from getting moved around, changed to camelCase, and copied to the help topic test; it and the access check that uses it have remained unchanged since then. The docblock was added in 2011 as part of an effort to fix Help module API documentation. Unfortunately, they got this one wrong. It never was an anonymous user. @charlliequadros's changes are correct.Comment #7
mstrelan commentedWhile we're at it let's fix the @var type. Since #3560202: UserCreationTrait::create* methods can never return false
$this->createUser()cannot return FALSE (it never could anyway). Plus$this->setCurrentUser()doesn't accept FALSE either.If we're fixing this @var type we should fix the same for
$adminUser. I would also go as far to say we should swap these to be native typed properties instead of @var docs.Comment #8
mstrelan commentedComment #9
charlliequadros commentedComment #10
mstrelan commentedLooks great. Can we update the IS to match?
Comment #11
dcam commentedI took care of it.
Looks good to me too. Back to RTBC.
Comment #13
godotislateNot sure this is worth going to 11.x, so committed 7156a08 and pushed to main. Thanks!