You are here

public function UserRouteTest::testUserRoutes in Username Enumeration Prevention 8

Tests user routes.

@dataProvider providerTestUserRoutes

Parameters

string $routeId: Route ID.

array $routeParameters: Additional route parameters.

array $modules: Enable these modules.

int $expectedStatus: Expected HTTP status.

File

tests/src/Functional/UserRouteTest.php, line 34

Class

UserRouteTest
Performs integration tests on UserRouteEventSubscriber.

Namespace

Drupal\Tests\username_enumeration_prevention\Functional

Code

public function testUserRoutes(string $routeId, array $routeParameters, array $modules, int $expectedStatus) {
  $user = $this
    ->drupalCreateUser();
  \Drupal::service('module_installer')
    ->install($modules);
  $routeParameters['user'] = $user
    ->id();
  $this
    ->drupalGet(Url::fromRoute($routeId, $routeParameters));
  $this
    ->assertSession()
    ->statusCodeEquals($expectedStatus);
}