function PathPluginBaseTest::testCollectRoutes

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

Tests the collectRoutes method.

See also

\Drupal\views\Plugin\views\display\PathPluginBase::collectRoutes()

File

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

Class

PathPluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\display\PathPluginBase @group views

Namespace

Drupal\Tests\views\Unit\Plugin\display

Code

public function testCollectRoutes() {
    list($view) = $this->setupViewExecutableAccessPlugin();
    $display = [];
    $display['display_plugin'] = 'page';
    $display['id'] = 'page_1';
    $display['display_options'] = [
        'path' => 'test_route',
    ];
    $this->pathPlugin
        ->initDisplay($view, $display);
    $collection = new RouteCollection();
    $result = $this->pathPlugin
        ->collectRoutes($collection);
    $this->assertEquals([
        'test_id.page_1' => 'view.test_id.page_1',
    ], $result);
    $route = $collection->get('view.test_id.page_1');
    $this->assertInstanceOf(Route::class, $route);
    $this->assertEquals('test_id', $route->getDefault('view_id'));
    $this->assertEquals('page_1', $route->getDefault('display_id'));
    $this->assertSame(FALSE, $route->getOption('returns_response'));
    $this->assertEquals('my views title', $route->getDefault('_title'));
}

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