You are here

public function DisplayCRUDTest::testAddDisplay in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php \Drupal\Tests\views_ui\Functional\DisplayCRUDTest::testAddDisplay()
  2. 10 core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php \Drupal\Tests\views_ui\Functional\DisplayCRUDTest::testAddDisplay()

Tests adding a display.

File

core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php, line 36

Class

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

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testAddDisplay() {

  // Show the master display.
  $this
    ->config('views.settings')
    ->set('ui.show.master_display', TRUE)
    ->save();
  $settings['page[create]'] = FALSE;
  $view = $this
    ->randomView($settings);
  $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
  $this
    ->drupalGet($path_prefix);

  // Add a new display.
  $this
    ->drupalPostForm(NULL, [], 'Add Page');
  $this
    ->assertLinkByHref($path_prefix . '/page_1', 0, 'Make sure after adding a display the new display appears in the UI');
  $this
    ->assertSession()
    ->linkNotExists('Master*', 'Make sure the master display is not marked as changed.');
  $this
    ->assertSession()
    ->linkExists('Page*', 0, 'Make sure the added display is marked as changed.');
  $this
    ->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/path", [
    'path' => 'test/path',
  ], t('Apply'));
  $this
    ->drupalPostForm(NULL, [], t('Save'));
}