function DuplicateTest::testDuplicateView

Same name in other branches
  1. 8.9.x core/modules/views_ui/tests/src/Functional/DuplicateTest.php \Drupal\Tests\views_ui\Functional\DuplicateTest::testDuplicateView()
  2. 10 core/modules/views_ui/tests/src/Functional/DuplicateTest.php \Drupal\Tests\views_ui\Functional\DuplicateTest::testDuplicateView()
  3. 11.x core/modules/views_ui/tests/src/Functional/DuplicateTest.php \Drupal\Tests\views_ui\Functional\DuplicateTest::testDuplicateView()

Checks if duplicated view exists and has correct label.

File

core/modules/views_ui/tests/src/Functional/DuplicateTest.php, line 29

Class

DuplicateTest
Tests the UI for view duplicate tool.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testDuplicateView() {
    // Create random view.
    $random_view = $this->randomView();
    // Initialize array for duplicated view.
    $view = [];
    // Generate random label and id for new view.
    $view['label'] = $this->randomMachineName(255);
    $view['id'] = strtolower($this->randomMachineName(128));
    // Duplicate view.
    $this->drupalGet('admin/structure/views/view/' . $random_view['id'] . '/duplicate');
    $this->submitForm($view, 'Duplicate');
    // Assert that the page URL is correct.
    $this->assertSession()
        ->addressEquals('admin/structure/views/view/' . $view['id']);
    // Assert that the page title is correctly displayed.
    $this->assertSession()
        ->pageTextContains($view['label']);
}

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