You are here

public function ParamConverterManagerTest::testConvertMissingParam in Drupal 10

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

@covers ::convert

File

core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php, line 224

Class

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

Namespace

Drupal\Tests\Core\ParamConverter

Code

public function testConvertMissingParam() {
  $route = new Route('/test/{id}');
  $parameters = [
    'id' => [
      'converter' => 'test_convert',
    ],
  ];
  $route
    ->setOption('parameters', $parameters);
  $defaults = [
    RouteObjectInterface::ROUTE_OBJECT => $route,
    RouteObjectInterface::ROUTE_NAME => 'test_route',
    'id' => 1,
  ];
  $converter = $this
    ->createMock('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
    ->expectException(ParamNotConvertedException::class);
  $this
    ->expectExceptionMessage('The "id" parameter was not converted for the path "/test/{id}" (route name: "test_route")');
  $this->manager
    ->convert($defaults);
}