function ParamConversionEnhancerTest::testEnhance
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php \Drupal\Tests\Core\Enhancer\ParamConversionEnhancerTest::testEnhance()
- 8.9.x core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php \Drupal\Tests\Core\Enhancer\ParamConversionEnhancerTest::testEnhance()
- 10 core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php \Drupal\Tests\Core\Enhancer\ParamConversionEnhancerTest::testEnhance()
@covers ::enhance
File
-
core/
tests/ Drupal/ Tests/ Core/ Enhancer/ ParamConversionEnhancerTest.php, line 43
Class
- ParamConversionEnhancerTest
- @coversDefaultClass \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer @group Enhancer
Namespace
Drupal\Tests\Core\EnhancerCode
public function testEnhance() : void {
$route = new Route('/test/{id}/{literal}/{null}');
$raw_variables = [
'id' => 1,
'literal' => 'this is a literal',
'null' => NULL,
];
$defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
] + $raw_variables;
$expected = $defaults;
$expected['id'] = 'something_better!';
$expected['_raw_variables'] = new InputBag($raw_variables);
$this->paramConverterManager
->expects($this->once())
->method('convert')
->with($this->isType('array'))
->willReturn($expected);
$result = $this->paramConversionEnhancer
->enhance($defaults, new Request());
$this->assertEquals($expected, $result);
// Now run with the results as the new defaults to ensure that the
// conversion is just run once.
$result = $this->paramConversionEnhancer
->enhance($result, new Request());
$this->assertEquals($expected, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.