class UserRequirementsTest

Same name in this branch
  1. main core/modules/user/tests/src/Kernel/UserRequirementsTest.php \Drupal\Tests\user\Kernel\UserRequirementsTest
Same name and namespace in other branches
  1. 11.x core/modules/user/tests/src/Kernel/UserRequirementsTest.php \Drupal\Tests\user\Kernel\UserRequirementsTest
  2. 11.x core/modules/user/tests/src/Functional/UserRequirementsTest.php \Drupal\Tests\user\Functional\UserRequirementsTest
  3. 10 core/modules/user/tests/src/Functional/UserRequirementsTest.php \Drupal\Tests\user\Functional\UserRequirementsTest

Tests the requirements checks of the User module.

Attributes

#[Group('user')] #[RunTestsInSeparateProcesses]

Hierarchy

Expanded class hierarchy of UserRequirementsTest

File

core/modules/user/tests/src/Functional/UserRequirementsTest.php, line 14

Namespace

Drupal\Tests\user\Functional
View source
class UserRequirementsTest extends BrowserTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * Tests that the requirements check can detect a missing anonymous user.
   */
  public function testAnonymousUser() : void {
    // Remove the anonymous user.
    \Drupal::database()->delete('users')
      ->condition('uid', 0)
      ->execute();
    $this->drupalLogin($this->drupalCreateUser([
      'access administration pages',
      'administer site configuration',
    ]));
    $this->drupalGet('/admin/reports/status');
    $this->assertSession()
      ->statusCodeEquals(200);
    $this->assertSession()
      ->pageTextContains("The anonymous user does not exist.");
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.