public function PathPluginBaseTest::testCollectRoutesWithNamedParameters in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest::testCollectRoutesWithNamedParameters()
Tests the collectRoutes method with a path containing named parameters.
See also
\Drupal\views\Plugin\views\display\PathPluginBase::collectRoutes()
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ display/ PathPluginBaseTest.php, line 268 - Contains \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest.
Class
- PathPluginBaseTest
- @coversDefaultClass \Drupal\views\Plugin\views\display\PathPluginBase @group views
Namespace
Drupal\Tests\views\Unit\Plugin\displayCode
public function testCollectRoutesWithNamedParameters() {
/** @var \Drupal\views\ViewExecutable|\PHPUnit_Framework_MockObject_MockObject $view */
list($view) = $this
->setupViewExecutableAccessPlugin();
$view->argument = array();
$view->argument['nid'] = $this
->getMockBuilder('Drupal\\views\\Plugin\\views\\argument\\ArgumentPluginBase')
->disableOriginalConstructor()
->getMock();
$display = array();
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
$display['display_options'] = array(
'path' => 'test_route/%node/example',
);
$this->pathPlugin
->initDisplay($view, $display);
$collection = new RouteCollection();
$result = $this->pathPlugin
->collectRoutes($collection);
$this
->assertEquals(array(
'test_id.page_1' => 'view.test_id.page_1',
), $result);
$route = $collection
->get('view.test_id.page_1');
$this
->assertTrue($route instanceof Route);
$this
->assertEquals('/test_route/{node}/example', $route
->getPath());
$this
->assertEquals('test_id', $route
->getDefault('view_id'));
$this
->assertEquals('page_1', $route
->getDefault('display_id'));
$this
->assertEquals('my views title', $route
->getDefault('_title'));
$this
->assertEquals(array(
'arg_0' => 'node',
), $route
->getOption('_view_argument_map'));
}