Problem

  • WebTestBase::setUp() installs Drupal through the interactive installer, and creates a fake user object for uid 1 and makes that available as $this->root_user, but the object does not contain a uid.
  • The lack of a uid breaks WebTestBase::drupalCreateNode(), which tries to use the uid of the currently logged in user (which may be $this->root_user).

Proposed solution

  1. Just add a ::$uid property with value 1 there.
  2. No need to (re)load the entire entity of uid 1 (performance). It's OK if $this->root_user is a mock stdClass object.
  3. No need for adding tests for this.
CommentFileSizeAuthor
drupal8.test-root-user-uid.0.patch617 bytessun
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Status: Needs review » Reviewed & tested by the community

Ran the second time into this in another current feature request #1751210: Convert URL alias form element into a field and field widget, so let's move forward here.

tim.plunkett’s picture

I'll +1 the RTBC, because sun shouldn't have himself ;)

I haven't hit this yet, but I've been using $this->root_user more, and this would have been annoying had I hit it.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.