You are here

public function ParamConverterManagerTest::testConvertMissingParam in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php \Drupal\Tests\Core\ParamConverter\ParamConverterManagerTest::testConvertMissingParam()

@covers ::convert

@expectedException \Drupal\Core\ParamConverter\ParamNotConvertedException @expectedExceptionMessage The "id" parameter was not converted for the path "/test/{id}" (route name: "test_route")

File

core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php, line 232
Contains \Drupal\Tests\Core\ParamConverter\ParamConverterManagerTest.

Class

ParamConverterManagerTest
@coversDefaultClass \Drupal\Core\ParamConverter\ParamConverterManager @group ParamConverter

Namespace

Drupal\Tests\Core\ParamConverter

Code

public function testConvertMissingParam() {
  $route = new Route('/test/{id}');
  $parameters = array(
    'id' => array(
      'converter' => 'test_convert',
    ),
  );
  $route
    ->setOption('parameters', $parameters);
  $defaults = array(
    RouteObjectInterface::ROUTE_OBJECT => $route,
    RouteObjectInterface::ROUTE_NAME => 'test_route',
    'id' => 1,
  );
  $converter = $this
    ->getMock('Drupal\\Core\\ParamConverter\\ParamConverterInterface');
  $converter
    ->expects($this
    ->any())
    ->method('convert')
    ->with(1, $this
    ->isType('array'), 'id', $this
    ->isType('array'))
    ->will($this
    ->returnValue(NULL));
  $this->manager
    ->addConverter($converter, 'test_convert');
  $this->manager
    ->convert($defaults);
}