You are here

public function RouteMatchTestBase::testGetParameter in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php \Drupal\Tests\Core\Routing\RouteMatchTestBase::testGetParameter()
  2. 9 core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php \Drupal\Tests\Core\Routing\RouteMatchTestBase::testGetParameter()

@covers ::getParameter @covers \Drupal\Core\Routing\RouteMatch::getParameterNames @dataProvider routeMatchProvider

File

core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php, line 100

Class

RouteMatchTestBase
Base test class for testing classes implementing the route match interface.

Namespace

Drupal\Tests\Core\Routing

Code

public function testGetParameter(RouteMatchInterface $route_match, Route $route, $parameters, $expected_filtered_parameters) {
  foreach ($expected_filtered_parameters as $name => $expected_value) {
    $this
      ->assertSame($expected_value, $route_match
      ->getParameter($name));
  }
  foreach (array_diff_key($parameters, $expected_filtered_parameters) as $name) {
    $this
      ->assertNull($route_match
      ->getParameter($name));
  }
}