You are here

public function UserRouteTest::providerTestUserRoutes in Username Enumeration Prevention 8

Provides routes for testing.

File

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

Class

UserRouteTest
Performs integration tests on UserRouteEventSubscriber.

Namespace

Drupal\Tests\username_enumeration_prevention\Functional

Code

public function providerTestUserRoutes() : array {

  // user.module.
  $scenarios['user canonical'] = [
    'entity.user.canonical',
  ];
  $scenarios['user edit form'] = [
    'entity.user.edit_form',
  ];
  $scenarios['user cancel form'] = [
    'entity.user.cancel_form',
  ];
  $scenarios['cancel confirm 1'] = [
    'user.cancel_confirm',
  ];
  $scenarios['cancel confirm 2'] = [
    'user.cancel_confirm',
    [
      'timestamp' => 0,
      'hashed_pass' => 'foo',
    ],
  ];

  // contact.module.
  $scenarios['contact user contact form'] = [
    'entity.user.contact_form',
    [],
    [
      'contact',
    ],
  ];

  // shortcut.module.
  $scenarios['user shortcut list'] = [
    'shortcut.set_switch',
  ];
  $data = [];
  foreach ($scenarios as $key => $scenario) {
    $scenario = $scenario + array_fill_keys(range(1, 2), []);

    // Test Drupal user routes return 403 out of the box. We use these to test
    // if core changed the behaviour of these routes, and now 404.
    $data['without uep ' . $key] = $scenario + [
      3 => 403,
    ];
    $scenario[2][] = 'username_enumeration_prevention';
    $data['with uep ' . $key] = $scenario + [
      3 => 404,
    ];
  }
  return $data;
}