public function ParamConverterManagerTest::testSetRouteParameterConverters in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php \Drupal\Tests\Core\ParamConverter\ParamConverterManagerTest::testSetRouteParameterConverters()
@covers ::setRouteParameterConverters
@dataProvider providerTestSetRouteParameterConverters
File
- core/
tests/ Drupal/ Tests/ Core/ ParamConverter/ ParamConverterManagerTest.php, line 130
Class
- ParamConverterManagerTest
- @coversDefaultClass \Drupal\Core\ParamConverter\ParamConverterManager @group ParamConverter
Namespace
Drupal\Tests\Core\ParamConverterCode
public function testSetRouteParameterConverters($path, $parameters = NULL, $expected = NULL) {
$converter = $this
->createMock('Drupal\\Core\\ParamConverter\\ParamConverterInterface');
$converter
->expects($this
->any())
->method('applies')
->with($this
->anything(), 'id', $this
->anything())
->will($this
->returnValue(TRUE));
$this->manager
->addConverter($converter, 'applied');
$route = new Route($path);
if ($parameters) {
$route
->setOption('parameters', $parameters);
}
$collection = new RouteCollection();
$collection
->add('test_route', $route);
$this->manager
->setRouteParameterConverters($collection);
foreach ($collection as $route) {
$result = $route
->getOption('parameters');
if ($expected) {
$this
->assertSame($expected, $result['id']['converter']);
}
else {
$this
->assertNull($result);
}
}
}