function YamlRouteDiscoveryTest::testStringMethodsAndSchemes

Same name and namespace in other branches
  1. main core/tests/Drupal/KernelTests/Core/Routing/YamlRouteDiscoveryTest.php \Drupal\KernelTests\Core\Routing\YamlRouteDiscoveryTest::testStringMethodsAndSchemes()

Tests that string values for methods and schemes are supported.

Symfony's route constructor accepts a single method or scheme as a string, so routing.yml files may use strings as well as arrays.

See also

https://www.drupal.org/node/3608776

File

core/tests/Drupal/KernelTests/Core/Routing/YamlRouteDiscoveryTest.php, line 34

Class

YamlRouteDiscoveryTest
Tests \Drupal\Core\Routing\YamlRouteDiscovery.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testStringMethodsAndSchemes() : void {
  $route = $this->container
    ->get('router.route_provider')
    ->getRouteByName('router_test.string_method_scheme');
  $this->assertSame([
    'GET',
  ], $route->getMethods());
  $this->assertSame([
    'https',
  ], $route->getSchemes());
}

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