You are here

public function DisplayCRUDTest::testRemoveDisplay in Zircon Profile 8.0

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

Tests removing a display.

File

core/modules/views_ui/src/Tests/DisplayCRUDTest.php, line 60
Contains \Drupal\views_ui\Tests\DisplayCRUDTest.

Class

DisplayCRUDTest
Tests creation, retrieval, updating, and deletion of displays in the Web UI.

Namespace

Drupal\views_ui\Tests

Code

public function testRemoveDisplay() {
  $view = $this
    ->randomView();
  $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
  $this
    ->drupalGet($path_prefix . '/default');
  $this
    ->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is no delete button on the default display.');
  $this
    ->drupalGet($path_prefix . '/page_1');
  $this
    ->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display.');

  // Delete the page, so we can test the undo process.
  $this
    ->drupalPostForm($path_prefix . '/page_1', array(), 'Delete Page');
  $this
    ->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there a undo button on the page display after deleting.');
  $element = $this
    ->xpath('//a[contains(@href, :href) and contains(@class, :class)]', array(
    ':href' => $path_prefix . '/page_1',
    ':class' => 'views-display-deleted-link',
  ));
  $this
    ->assertTrue(!empty($element), 'Make sure the display link is marked as to be deleted.');
  $element = $this
    ->xpath('//a[contains(@href, :href) and contains(@class, :class)]', array(
    ':href' => $path_prefix . '/page_1',
    ':class' => 'views-display-deleted-link',
  ));
  $this
    ->assertTrue(!empty($element), 'Make sure the display link is marked as to be deleted.');

  // Undo the deleting of the display.
  $this
    ->drupalPostForm($path_prefix . '/page_1', array(), 'Undo delete of Page');
  $this
    ->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there is no undo button on the page display after reverting.');
  $this
    ->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display after the reverting.');

  // Now delete again and save the view.
  $this
    ->drupalPostForm($path_prefix . '/page_1', array(), 'Delete Page');
  $this
    ->drupalPostForm(NULL, array(), t('Save'));
  $this
    ->assertNoLinkByHref($path_prefix . '/page_1', 'Make sure there is no display tab for the deleted display.');
}