function DisplayCRUDTest::testAddDisplay

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. 8.9.x core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php \Drupal\Tests\views_ui\Functional\DisplayCRUDTest::testAddDisplay()
  3. 11.x 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 38

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 default display.
    $this->config('views.settings')
        ->set('ui.show.default_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->submitForm([], 'Add Page');
    $this->assertSession()
        ->linkByHrefExists($path_prefix . '/page_1', 0, 'Make sure after adding a display the new display appears in the UI');
    $this->assertSession()
        ->linkNotExists('Default*', 'Make sure the default display is not marked as changed.');
    $this->assertSession()
        ->linkExists('Page*', 0, 'Make sure the added display is marked as changed.');
    $this->drupalGet("admin/structure/views/nojs/display/{$view['id']}/page_1/path");
    $this->submitForm([
        'path' => 'test/path',
    ], 'Apply');
    $this->submitForm([], 'Save');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.