public function ParamConverterManagerTest::testConvertMissingParam in Drupal 8
Same name and namespace in other branches
- 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\ParamConverterCode
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);
}