You are here

public function PathValidatorTest::testIsValidWithMethodNotAllowed in Drupal 10

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

@covers ::isValid @covers ::getPathAttributes

File

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

Class

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

Namespace

Drupal\Tests\Core\Path

Code

public function testIsValidWithMethodNotAllowed() {
  $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')
    ->willThrowException(new MethodNotAllowedException([]));
  $this->pathProcessor
    ->expects($this
    ->once())
    ->method('processInbound')
    ->willReturnArgument(0);
  $this
    ->assertFalse($this->pathValidator
    ->isValid('test-path'));
}