public function UrlTest::testUrlFromRequest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testUrlFromRequest()
Tests creating a Url from a request.
File
- core/
tests/ Drupal/ Tests/ Core/ UrlTest.php, line 123 - Contains \Drupal\Tests\Core\UrlTest.
Class
- UrlTest
- @coversDefaultClass \Drupal\Core\Url @group UrlTest
Namespace
Drupal\Tests\CoreCode
public function testUrlFromRequest() {
$this->router
->expects($this
->at(0))
->method('matchRequest')
->with($this
->getRequestConstraint('/node'))
->willReturn([
RouteObjectInterface::ROUTE_NAME => 'view.frontpage.page_1',
'_raw_variables' => new ParameterBag(),
]);
$this->router
->expects($this
->at(1))
->method('matchRequest')
->with($this
->getRequestConstraint('/node/1'))
->willReturn([
RouteObjectInterface::ROUTE_NAME => 'node_view',
'_raw_variables' => new ParameterBag([
'node' => '1',
]),
]);
$this->router
->expects($this
->at(2))
->method('matchRequest')
->with($this
->getRequestConstraint('/node/2/edit'))
->willReturn([
RouteObjectInterface::ROUTE_NAME => 'node_edit',
'_raw_variables' => new ParameterBag([
'node' => '2',
]),
]);
$urls = array();
foreach ($this->map as $index => $values) {
$path = array_pop($values);
$url = Url::createFromRequest(Request::create("{$path}"));
$expected = Url::fromRoute($values[0], $values[1], $values[2]);
$this
->assertEquals($expected, $url);
$urls[$index] = $url;
}
return $urls;
}