function ParamConversionEnhancerTest::testCopyRawVariables

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php \Drupal\Tests\Core\Enhancer\ParamConversionEnhancerTest::testCopyRawVariables()
  2. 10 core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php \Drupal\Tests\Core\Enhancer\ParamConversionEnhancerTest::testCopyRawVariables()
  3. 11.x 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\Enhancer

Code

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'))
        ->will($this->returnCallback(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);
}

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