public function ParamConversionEnhancerTest::testCopyRawVariables in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php \Drupal\Tests\Core\Enhancer\ParamConversionEnhancerTest::testCopyRawVariables()
@covers ::copyRawVariables
File
- core/
tests/ Drupal/ Tests/ Core/ Enhancer/ ParamConversionEnhancerTest.php, line 76
Class
- ParamConversionEnhancerTest
- @coversDefaultClass \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer @group Enhancer
Namespace
Drupal\Tests\Core\EnhancerCode
public function testCopyRawVariables() {
$route = new Route('/test/{id}');
$defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
'id' => '1',
];
// Set one default to mirror another by reference.
$defaults['bar'] =& $defaults['id'];
$this->paramConverterManager
->expects($this
->any())
->method('convert')
->with($this
->isType('array'))
->willReturnCallback(function ($defaults) {
// Convert the mirrored default to another value.
$defaults['bar'] = '2';
return $defaults;
});
$expected = new ParameterBag([
'id' => 1,
]);
$result = $this->paramConversionEnhancer
->enhance($defaults, new Request());
$this
->assertEquals($result['_raw_variables'], $expected);
}