You are here

public function AuthenticationManagerTest::testDefaultFilter in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php \Drupal\Tests\Core\Authentication\AuthenticationManagerTest::testDefaultFilter()
  2. 9 core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php \Drupal\Tests\Core\Authentication\AuthenticationManagerTest::testDefaultFilter()

@covers ::defaultFilter @covers ::applyFilter

@dataProvider providerTestDefaultFilter

File

core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php, line 31
Contains \Drupal\Tests\Core\Authentication\AuthenticationManagerTest.

Class

AuthenticationManagerTest
@coversDefaultClass \Drupal\Core\Authentication\AuthenticationManager @group Authentication

Namespace

Drupal\Tests\Core\Authentication

Code

public function testDefaultFilter($applies, $has_route, $auth_option, $provider_id, $global) {
  $auth_provider = $this
    ->createMock('Drupal\\Core\\Authentication\\AuthenticationProviderInterface');
  $auth_collector = new AuthenticationCollector();
  $auth_collector
    ->addProvider($auth_provider, $provider_id, 0, $global);
  $authentication_manager = new AuthenticationManager($auth_collector);
  $request = new Request();
  if ($has_route) {
    $route = new Route('/example');
    if ($auth_option) {
      $route
        ->setOption('_auth', $auth_option);
    }
    $request->attributes
      ->set(RouteObjectInterface::ROUTE_OBJECT, $route);
  }
  $this
    ->assertSame($applies, $authentication_manager
    ->appliesToRoutedRequest($request, FALSE));
}