You are here

protected function AreaDisplayLinkTest::assertRenderedDisplayLinks in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php \Drupal\Tests\views\Kernel\Handler\AreaDisplayLinkTest::assertRenderedDisplayLinks()
  2. 10 core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php \Drupal\Tests\views\Kernel\Handler\AreaDisplayLinkTest::assertRenderedDisplayLinks()

Assert the display links are correctly rendered for a display.

Parameters

\Drupal\views\ViewExecutable $view: The view to check.

string $display_id: The display ID to check the links for.

1 call to AreaDisplayLinkTest::assertRenderedDisplayLinks()
AreaDisplayLinkTest::testAreaDisplayLink in core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php
Tests the views area display_link handler.

File

core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php, line 323

Class

AreaDisplayLinkTest
Tests the core views_handler_area_display_link handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function assertRenderedDisplayLinks(ViewExecutable $view, $display_id) {
  $page_1_active = $display_id === 'page_1' ? ' is-active' : '';
  $page_2_active = $display_id === 'page_2' ? ' is-active' : '';
  $view
    ->destroy();
  $view
    ->setDisplay($display_id);
  $this
    ->executeView($view);
  $this
    ->assertSame('<a href="/page_1" class="views-display-link views-display-link-page_1' . $page_1_active . '">Page 1</a>', $this
    ->renderDisplayLink($view, 'display_link_1'));
  $this
    ->assertSame('<a href="/page_2" class="views-display-link views-display-link-page_2' . $page_2_active . '">Page 2</a>', $this
    ->renderDisplayLink($view, 'display_link_2'));

  // Assert the exposed filters, pager and contextual links are passed
  // correctly in the links.
  $view
    ->destroy();
  $view
    ->setDisplay($display_id);
  $view
    ->setExposedInput([
    'name' => 'John',
    'sort_by' => 'created',
    'sort_order' => 'ASC',
  ]);
  $view
    ->setCurrentPage(2);
  $this
    ->executeView($view, [
    1,
  ]);
  $this
    ->assertSame('<a href="/page_1/1?name=John&amp;sort_by=created&amp;sort_order=ASC&amp;page=1" class="views-display-link views-display-link-page_1' . $page_1_active . '">Page 1</a>', $this
    ->renderDisplayLink($view, 'display_link_1'));
  $this
    ->assertSame('<a href="/page_2/1?name=John&amp;sort_by=created&amp;sort_order=ASC&amp;page=1" class="views-display-link views-display-link-page_2' . $page_2_active . '">Page 2</a>', $this
    ->renderDisplayLink($view, 'display_link_2'));
}