function AttributeRouteDiscoveryTest::testClassGlobalsInheritance
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Routing/AttributeRouteDiscoveryTest.php \Drupal\Tests\Core\Routing\AttributeRouteDiscoveryTest::testClassGlobalsInheritance()
Tests that a method inherits class-level globals.
File
-
core/
tests/ Drupal/ Tests/ Core/ Routing/ AttributeRouteDiscoveryTest.php, line 111
Class
Namespace
Drupal\Tests\Core\RoutingCode
public function testClassGlobalsInheritance() : void {
// The route name is the class prefix + method name.
$route = $this->routeCollection
->get('router_test.class_inherits');
$this->assertNotNull($route);
// Path is prefixed with the class path.
$this->assertSame('/test_class_attribute/inherits', $route->getPath());
// Controller is automatically configured.
$this->assertSame(TestClassAttribute::class . '::inherits', $route->getDefault('_controller'));
// Everything else is inherited.
$this->assertSame('from_class', $route->getDefault('default_a'));
$this->assertSame('Class title', $route->getDefault('_title'));
$this->assertSame('TRUE', $route->getRequirement('_access'));
$this->assertSame('from_class', $route->getOption('option_a'));
$this->assertSame(RouteCompiler::class, $route->getOption('compiler_class'));
$this->assertSame([
'GET',
], $route->getMethods());
$this->assertSame([
'http',
], $route->getSchemes());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.