function PathPluginBaseTest::testCollectRoutesWithSpecialRouteName

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest::testCollectRoutesWithSpecialRouteName()
  2. 10 core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest::testCollectRoutesWithSpecialRouteName()
  3. 11.x core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest::testCollectRoutesWithSpecialRouteName()

Tests the collect routes method with an alternative route name in the UI.

File

core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php, line 203

Class

PathPluginBaseTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21display%21PathPluginBase.php/class/PathPluginBase/9" title="The base display plugin for path/callbacks. This is used for pages and feeds." class="local">\Drupal\views\Plugin\views\display\PathPluginBase</a> @group views

Namespace

Drupal\Tests\views\Unit\Plugin\display

Code

public function testCollectRoutesWithSpecialRouteName() {
    [
        $view,
    ] = $this->setupViewExecutableAccessPlugin();
    $display = [];
    $display['display_plugin'] = 'page';
    $display['id'] = 'page_1';
    $display['display_options'] = [
        'path' => 'test_route',
        'route_name' => 'test_route',
    ];
    $this->pathPlugin
        ->initDisplay($view, $display);
    $collection = new RouteCollection();
    $result = $this->pathPlugin
        ->collectRoutes($collection);
    $this->assertEquals([
        'test_id.page_1' => 'test_route',
    ], $result);
    $route = $collection->get('test_route');
    $this->assertInstanceOf(Route::class, $route);
    $this->assertEquals('test_id', $route->getDefault('view_id'));
    $this->assertEquals('page_1', $route->getDefault('display_id'));
    $this->assertEquals('Drupal\\views\\Routing\\ViewPageController::getTitle', $route->getDefault('_title_callback'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.