You are here

function OverrideDisplaysTest::testRevertAllDisplays in Views (for Drupal 7) 8.3

Tests that the revert to all displays select-option works as expected.

File

lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php, line 178
Definition of Drupal\views\Tests\UI\OverrideDisplaysTest.

Class

OverrideDisplaysTest
Tests that displays can be correctly overridden via the user interface.

Namespace

Drupal\views\Tests\UI

Code

function testRevertAllDisplays() {

  // Create a basic view with a page, block.
  // Because there is both a title on page and block we expect the title on
  // the block be overriden.
  $view['human_name'] = $this
    ->randomName(16);
  $view['name'] = strtolower($this
    ->randomName(16));
  $view['page[create]'] = 1;
  $view['page[title]'] = $this
    ->randomName(16);
  $view['page[path]'] = $this
    ->randomName(16);
  $view['block[create]'] = 1;
  $view['block[title]'] = $this
    ->randomName(16);
  $this
    ->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));

  // Revert the title of the block back to the default ones, but submit some
  // new values to be sure that the new value is not stored.
  $edit = array();
  $edit['title'] = $new_block_title = $this
    ->randomName();
  $edit['override[dropdown]'] = 'default_revert';
  $this
    ->drupalPost("admin/structure/views/nojs/display/{$view['name']}/block_1/title", $edit, t('Apply'));
  $this
    ->drupalPost("admin/structure/views/view/{$view['name']}/edit/block_1", array(), t('Save'));
  $this
    ->assertText($view['page[title]']);
}