You are here

public function DisplayTest::testReorderDisplay in Views (for Drupal 7) 8.3

Tests reordering of displays.

File

lib/Drupal/views/Tests/UI/DisplayTest.php, line 97
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 testReorderDisplay() {
  $view = array(
    'block[create]' => TRUE,
  );
  $view = $this
    ->randomView($view);
  $path_prefix = 'admin/structure/views/view/' . $view['name'] . '/edit';
  $edit = array();
  $this
    ->drupalPost($path_prefix, $edit, t('Save'));
  $this
    ->clickLink(t('reorder displays'));
  $this
    ->assertTrue($this
    ->xpath('//tr[@id="display-row-default"]'), 'Make sure the default display appears on the reorder listing');
  $this
    ->assertTrue($this
    ->xpath('//tr[@id="display-row-page_1"]'), 'Make sure the page display appears on the reorder listing');
  $this
    ->assertTrue($this
    ->xpath('//tr[@id="display-row-block_1"]'), 'Make sure the block display appears on the reorder listing');

  // Put the block display in front of the page display.
  $edit = array(
    'page_1[weight]' => 2,
    'block_1[weight]' => 1,
  );
  $this
    ->drupalPost(NULL, $edit, t('Apply'));
  $this
    ->drupalPost(NULL, array(), t('Save'));
  $view = views_get_view($view['name']);
  $this
    ->assertEqual($view->storage->display['default']['position'], 0, 'Make sure the master display comes first.');
  $this
    ->assertEqual($view->storage->display['block_1']['position'], 1, 'Make sure the block display comes before the page display.');
  $this
    ->assertEqual($view->storage->display['page_1']['position'], 2, 'Make sure the page display comes after the block display.');
}