function PathPluginBaseTest::testCollectRoutesWithDisplayReturnResponse

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

Tests the collectRoutes method with a display returning a response.

See also

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

File

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

Class

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

Namespace

Drupal\Tests\views\Unit\Plugin\display

Code

public function testCollectRoutesWithDisplayReturnResponse() : void {
    [
        $view,
    ] = $this->setupViewExecutableAccessPlugin();
    $display = [];
    $display['display_plugin'] = 'page';
    $display['id'] = 'page_1';
    $display['display_options'] = [
        'path' => 'test_route',
    ];
    $this->pathPlugin = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\PathPluginBase')
        ->setConstructorArgs([
        [],
        'path_base',
        [
            'returns_response' => TRUE,
        ],
        $this->routeProvider,
        $this->state,
    ])
        ->onlyMethods([])
        ->getMock();
    $this->pathPlugin
        ->initDisplay($view, $display);
    $collection = new RouteCollection();
    $this->pathPlugin
        ->collectRoutes($collection);
    $route = $collection->get('view.test_id.page_1');
    $this->assertTrue($route->getOption('returns_response'));
    $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.