You are here

public function ParamConversionEnhancerTest::testCopyRawVariables in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 81
Contains \Drupal\Tests\Core\Enhancer\ParamConversionEnhancerTest.

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 = array(
    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(array(
    'id' => 1,
  ));
  $result = $this->paramConversionEnhancer
    ->enhance($defaults, new Request());
  $this
    ->assertEquals($result['_raw_variables'], $expected);
}