public function DisplayTest::testRemoveDisplay

Tests removing a display.

File

drupal/core/modules/views/lib/Drupal/views/Tests/UI/DisplayTest.php, line 52
Definition of Drupal\views\Tests\UI\DisplayTest.

Class

DisplayTest
Tests the handling of displays in the UI, adding removing etc.

Namespace

Drupal\views\Tests\UI

Code

public function testRemoveDisplay() {
  $view = $this
    ->randomView();
  $path_prefix = 'admin/structure/views/view/' . $view['name'] . '/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
    ->drupalPost($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.');
  $this
    ->assertTrue($this
    ->xpath('//a[contains(@class, :class)]', array(
    ':class' => 'views-display-deleted-link',
  )), 'Make sure the display link is marked as to be deleted.');

  // Undo the deleting of the display.
  $this
    ->drupalPost($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
    ->drupalPost($path_prefix . '/page_1', array(), 'delete Page');
  $this
    ->drupalPost(NULL, array(), t('Save'));
  $this
    ->assertNoLinkByHref($path_prefix . '/page_1', 'Make sure there is no display tab for the deleted display.');
}