function DisplayTest::testLinkDisplay
Same name in other branches
- 9 core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testLinkDisplay()
- 10 core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testLinkDisplay()
- 11.x core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testLinkDisplay()
Tests the link-display setting.
File
-
core/
modules/ views_ui/ tests/ src/ Functional/ DisplayTest.php, line 151
Class
- DisplayTest
- Tests the display UI.
Namespace
Drupal\Tests\views_ui\FunctionalCode
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)]", [
':path' => $link_display_path,
]);
$this->assertEqual($result[0]->getHtml(), 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, [
'link_display' => 'page_1',
], t('Apply'));
// The form redirects to the master display.
$this->drupalGet($path);
$result = $this->xpath("//a[contains(@href, :path)]", [
':path' => $link_display_path,
]);
$this->assertEqual($result[0]->getHtml(), 'Page', 'Make sure that the link option summary shows the right linked display.');
$this->drupalPostForm($link_display_path, [
'link_display' => 'custom_url',
'link_url' => 'a-custom-url',
], t('Apply'));
// The form redirects to the master display.
$this->drupalGet($path);
$this->assertSession()
->linkExists(t('Custom URL'), 0, 'The link option has custom URL as summary.');
// Test the default link_url value for new display
$this->drupalPostForm(NULL, [], 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');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.