class RouteMatchTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php \Drupal\Tests\Core\Routing\RouteMatchTest
@coversDefaultClass \Drupal\Core\Routing\RouteMatch @group Routing
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\Core\Routing\RouteMatchTestBase
- class \Drupal\Tests\Core\Routing\RouteMatchTest
- class \Drupal\Tests\Core\Routing\RouteMatchTestBase
Expanded class hierarchy of RouteMatchTest
File
- core/
tests/ Drupal/ Tests/ Core/ Routing/ RouteMatchTest.php, line 20 - Contains \Drupal\Tests\Core\Routing\RouteMatchTest.
Namespace
Drupal\Tests\Core\RoutingView source
class RouteMatchTest extends RouteMatchTestBase {
/**
* {@inheritdoc}
*/
protected function getRouteMatch($name, Route $route, array $parameters, array $raw_parameters) {
return new RouteMatch($name, $route, $parameters, $raw_parameters);
}
/**
* @covers ::createFromRequest
* @covers ::__construct
*/
public function testRouteMatchFromRequest() {
$request = new Request();
// A request that hasn't been routed yet.
$route_match = RouteMatch::createFromRequest($request);
$this
->assertNull($route_match
->getRouteName());
$this
->assertNull($route_match
->getRouteObject());
$this
->assertSame(array(), $route_match
->getParameters()
->all());
$this
->assertNull($route_match
->getParameter('foo'));
$this
->assertSame(array(), $route_match
->getRawParameters()
->all());
$this
->assertNull($route_match
->getRawParameter('foo'));
// A routed request without parameter upcasting.
$route = new Route('/test-route/{foo}');
$request->attributes
->set(RouteObjectInterface::ROUTE_NAME, 'test_route');
$request->attributes
->set(RouteObjectInterface::ROUTE_OBJECT, $route);
$request->attributes
->set('foo', '1');
$route_match = RouteMatch::createFromRequest($request);
$this
->assertSame('test_route', $route_match
->getRouteName());
$this
->assertSame($route, $route_match
->getRouteObject());
$this
->assertSame(array(
'foo' => '1',
), $route_match
->getParameters()
->all());
$this
->assertSame(array(), $route_match
->getRawParameters()
->all());
// A routed request with parameter upcasting.
$foo = new \stdClass();
$foo->value = 1;
$request->attributes
->set('foo', $foo);
$request->attributes
->set('_raw_variables', new ParameterBag(array(
'foo' => '1',
)));
$route_match = RouteMatch::createFromRequest($request);
$this
->assertSame(array(
'foo' => $foo,
), $route_match
->getParameters()
->all());
$this
->assertSame(array(
'foo' => '1',
), $route_match
->getRawParameters()
->all());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteMatchTest:: |
protected | function |
Build a test route match object for the given implementation. Overrides RouteMatchTestBase:: |
|
RouteMatchTest:: |
public | function | @covers ::createFromRequest @covers ::__construct | |
RouteMatchTestBase:: |
public | function | Provide sets of parameters and expected parameters for parameter tests. | |
RouteMatchTestBase:: |
public | function | @covers ::getParameter @covers \Drupal\Core\Routing\RouteMatch::getParameterNames @dataProvider routeMatchProvider | |
RouteMatchTestBase:: |
public | function | @covers ::getParameters @covers \Drupal\Core\Routing\RouteMatch::getParameterNames @dataProvider routeMatchProvider | |
RouteMatchTestBase:: |
public | function | @covers ::getRawParameter @covers \Drupal\Core\Routing\RouteMatch::getParameterNames @dataProvider routeMatchProvider | |
RouteMatchTestBase:: |
public | function | @covers ::getRawParameters @covers \Drupal\Core\Routing\RouteMatch::getParameterNames @dataProvider routeMatchProvider | |
RouteMatchTestBase:: |
public | function | @covers ::getRouteName @dataProvider routeMatchProvider | |
RouteMatchTestBase:: |
public | function | @covers ::getRouteObject @dataProvider routeMatchProvider | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 259 |