function AttributeRouteDiscoveryTest::testAllRouteProperties

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Core/Routing/AttributeRouteDiscoveryTest.php \Drupal\Tests\Core\Routing\AttributeRouteDiscoveryTest::testAllRouteProperties()

Tests all supported route properties.

@legacy-covers ::onRouteBuild @legacy-covers ::addRoute

Attributes

#[IgnoreDeprecations]

File

core/tests/Drupal/Tests/Core/Routing/AttributeRouteDiscoveryTest.php, line 78

Class

AttributeRouteDiscoveryTest
Tests \Drupal\Core\Routing\AttributeRouteDiscovery.

Namespace

Drupal\Tests\Core\Routing

Code

public function testAllRouteProperties() : void {
  $route = $this->routeCollection
    ->get('router_test.all_properties');
  $this->assertNotNull($route);
  $this->assertSame('/test_all_properties/{parameter}', $route->getPath());
  $this->assertSame(TestAttributes::class . '::allProperties', $route->getDefault('_controller'));
  $this->assertSame('Test all properties', $route->getDefault('_title'));
  $this->assertSame('1', $route->getDefault('parameter'));
  $this->assertSame('TRUE', $route->getRequirement('_access'));
  $this->assertSame('\\d+', $route->getRequirement('parameter'));
  $options = $route->getOptions();
  $this->assertTrue($options['_admin_route']);
  $this->assertTrue($options['utf8']);
  $this->assertSame(RouteCompiler::class, $options['compiler_class']);
  $this->assertSame('{subdomain}.example.com', $route->getHost());
  $this->assertSame([
    'GET',
    'POST',
  ], $route->getMethods());
  $this->assertSame([
    'https',
  ], $route->getSchemes());
  $this->assertSame($route, $this->routeCollection
    ->get('router_test.all_properties_alias'));
  $this->expectDeprecation('Since drupal/core X.0.0: The "router_test.all_properties_deprecated" route is deprecated.');
  $this->assertSame($route, $this->routeCollection
    ->get('router_test.all_properties_deprecated'));
  // Auto-generated class::method alias.
  $this->assertSame($route, $this->routeCollection
    ->get(TestAttributes::class . '::allProperties'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.