function LoginCommandTest::testLoginInvalidUsers

Tests invalid login attempts.

Since we can only call expectException() once per test, we need each invocation to be a separate test. Therefore, we use a DataProvider to run each of these attempts individually.

Attributes

#[DataProvider('invalidUserProvider')]

File

core/modules/user/tests/src/Kernel/Command/LoginCommandTest.php, line 67

Class

LoginCommandTest
Tests user:login console command failure modes (blocked, user not found).

Namespace

Drupal\Tests\user\Kernel\Command

Code

public function testLoginInvalidUsers(string $property, string $value) : void {
  $this->expectException(\InvalidArgumentException::class);
  $this->expectExceptionMessage("Unable to load user by {$property}: {$value}");
  $tester = $this->buildLoginCommandTester();
  $tester->execute([
    '--' . $property => $value,
  ]);
}

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