function PathValidatorTest::testGetUrlIfValidWithQuery
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithQuery()
- 8.9.x core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithQuery()
- 10 core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithQuery()
Tests the getUrlIfValid() method with a query in the path.
@covers ::getUrlIfValid
File
-
core/
tests/ Drupal/ Tests/ Core/ Path/ PathValidatorTest.php, line 363
Class
- PathValidatorTest
- @coversDefaultClass \Drupal\Core\Path\PathValidator @group Routing
Namespace
Drupal\Tests\Core\PathCode
public function testGetUrlIfValidWithQuery() : void {
$this->account
->expects($this->once())
->method('hasPermission')
->with('link to any page')
->willReturn(FALSE);
$this->accessAwareRouter
->expects($this->once())
->method('match')
->with('/test-path?k=bar')
->willReturn([
RouteObjectInterface::ROUTE_NAME => 'test_route',
'_raw_variables' => new InputBag(),
]);
$this->pathProcessor
->expects($this->once())
->method('processInbound')
->willReturnArgument(0);
$url = $this->pathValidator
->getUrlIfValid('test-path?k=bar');
$this->assertInstanceOf('Drupal\\Core\\Url', $url);
$this->assertEquals('test_route', $url->getRouteName());
$this->assertEquals([
'k' => 'bar',
], $url->getOptions()['query']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.