You are here

public function PathPluginBaseTest::testCollectRoutesWithDisplayReturnResponse in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest::testCollectRoutesWithDisplayReturnResponse()
  2. 10 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 119
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\display

Code

public function testCollectRoutesWithDisplayReturnResponse() {
  list($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,
  ])
    ->setMethods(NULL)
    ->getMock();
  $this->pathPlugin
    ->initDisplay($view, $display);
  $collection = new RouteCollection();
  $this->pathPlugin
    ->collectRoutes($collection);
  $route = $collection
    ->get('view.test_id.page_1');
  $this
    ->assertSame(TRUE, $route
    ->getOption('returns_response'));
  $this
    ->assertEquals('my views title', $route
    ->getDefault('_title'));
}