public function ParamConversionEnhancerTest::testEnhance in Drupal 8
Same name and namespace in other branches
- 9 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 41
Class
- ParamConversionEnhancerTest
- @coversDefaultClass \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer @group Enhancer
Namespace
Drupal\Tests\Core\EnhancerCode
public function testEnhance() {
$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 ParameterBag($raw_variables);
$this->paramConverterManager
->expects($this
->once())
->method('convert')
->with($this
->isType('array'))
->will($this
->returnValue($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);
}