You are here

public function DisplayTest::testLinkDisplay in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views_ui/src/Tests/DisplayTest.php \Drupal\views_ui\Tests\DisplayTest::testLinkDisplay()

Tests the link-display setting.

File

core/modules/views_ui/src/Tests/DisplayTest.php, line 160
Contains \Drupal\views_ui\Tests\DisplayTest.

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\views_ui\Tests

Code

public function testLinkDisplay() {

  // Test setting the link display in the UI form.
  $path = 'admin/structure/views/view/test_display/edit/block_1';
  $link_display_path = 'admin/structure/views/nojs/display/test_display/block_1/link_display';

  // Test the link text displays 'None' and not 'Block 1'
  $this
    ->drupalGet($path);
  $result = $this
    ->xpath("//a[contains(@href, :path)]", array(
    ':path' => $link_display_path,
  ));
  $this
    ->assertEqual($result[0], t('None'), 'Make sure that the link option summary shows "None" by default.');
  $this
    ->drupalGet($link_display_path);
  $this
    ->assertFieldChecked('edit-link-display-0');

  // Test the default radio option on the link display form.
  $this
    ->drupalPostForm($link_display_path, array(
    'link_display' => 'page_1',
  ), t('Apply'));

  // The form redirects to the master display.
  $this
    ->drupalGet($path);
  $result = $this
    ->xpath("//a[contains(@href, :path)]", array(
    ':path' => $link_display_path,
  ));
  $this
    ->assertEqual($result[0], 'Page', 'Make sure that the link option summary shows the right linked display.');
  $this
    ->drupalPostForm($link_display_path, array(
    'link_display' => 'custom_url',
    'link_url' => 'a-custom-url',
  ), t('Apply'));

  // The form redirects to the master display.
  $this
    ->drupalGet($path);
  $this
    ->assertLink(t('Custom URL'), 0, 'The link option has custom url as summary.');

  // Test the default link_url value for new display
  $this
    ->drupalPostForm(NULL, array(), t('Add Block'));
  $this
    ->assertUrl('admin/structure/views/view/test_display/edit/block_2');
  $this
    ->clickLink(t('Custom URL'));
  $this
    ->assertFieldByName('link_url', 'a-custom-url');
}