You are here

public function PathValidatorTest::testIsValidWithPathAlias in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testIsValidWithPathAlias()

Tests the isValid() method with a path alias.

@covers ::isValid

File

core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php, line 167

Class

PathValidatorTest
@coversDefaultClass \Drupal\Core\Path\PathValidator @group Routing

Namespace

Drupal\Tests\Core\Path

Code

public function testIsValidWithPathAlias() {
  $this->account
    ->expects($this
    ->once())
    ->method('hasPermission')
    ->with('link to any page')
    ->willReturn(FALSE);
  $this->accessUnawareRouter
    ->expects($this
    ->never())
    ->method('match');
  $this->accessAwareRouter
    ->expects($this
    ->once())
    ->method('match')
    ->with('/test-path')
    ->willReturn([
    RouteObjectInterface::ROUTE_NAME => 'test_route',
    '_raw_variables' => new ParameterBag([
      'key' => 'value',
    ]),
  ]);
  $this->pathProcessor
    ->expects($this
    ->once())
    ->method('processInbound')
    ->with('/path-alias', $this
    ->anything())
    ->willReturn('/test-path');
  $this
    ->assertTrue($this->pathValidator
    ->isValid('path-alias'));
}