public function DisplayAttachmentTest::testRemoveAttachedDisplay in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php \Drupal\Tests\views_ui\Functional\DisplayAttachmentTest::testRemoveAttachedDisplay()
Tests the attachment working after the attached page was deleted.
File
- core/
modules/ views_ui/ tests/ src/ Functional/ DisplayAttachmentTest.php, line 72
Class
- DisplayAttachmentTest
- Tests the UI for the attachment display plugin.
Namespace
Drupal\Tests\views_ui\FunctionalCode
public function testRemoveAttachedDisplay() {
// Create a view.
$view = $this
->randomView();
$path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
$attachment_display_url = 'admin/structure/views/nojs/display/' . $view['id'] . '/attachment_1/displays';
// Open the Page display and create the attachment display.
$this
->drupalGet($path_prefix . '/page_1');
$this
->submitForm([], 'Add Attachment');
$this
->assertSession()
->pageTextContains('Not defined');
// Attach the Attachment to the Page display.
$this
->drupalGet($attachment_display_url);
$this
->submitForm([
'displays[page_1]' => 1,
], 'Apply');
$this
->submitForm([], 'Save');
// Open the Page display and mark it as deleted.
$this
->drupalGet($path_prefix . '/page_1');
$this
->assertSession()
->buttonExists('edit-displays-settings-settings-content-tab-content-details-top-actions-delete');
$this
->drupalGet($path_prefix . '/page_1');
$this
->submitForm([], 'Delete Page');
// Open the attachment display and save it.
$this
->drupalGet($path_prefix . '/attachment_1');
$this
->submitForm([], 'Save');
// Check that there is no warning for the removed page display.
$this
->assertSession()
->pageTextNotContains("Plugin ID 'page_1' was not found.");
// Check that the attachment is no longer linked to the removed display.
$this
->assertSession()
->pageTextContains('Not defined');
}