You are here

public function DuplicateTest::testDuplicateView in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/Tests/DuplicateTest.php \Drupal\views_ui\Tests\DuplicateTest::testDuplicateView()

Checks if duplicated view exists and has correct label.

File

core/modules/views_ui/src/Tests/DuplicateTest.php, line 26
Contains \Drupal\views_ui\Tests\DuplicateTest.

Class

DuplicateTest
Tests the UI for view duplicate tool.

Namespace

Drupal\views_ui\Tests

Code

public function testDuplicateView() {

  // Create random view.
  $random_view = $this
    ->randomView();

  // Initialize array for duplicated view.
  $view = array();

  // Generate random label and id for new view.
  $view['label'] = $this
    ->randomMachineName(255);
  $view['id'] = strtolower($this
    ->randomMachineName(128));

  // Duplicate view.
  $this
    ->drupalPostForm('admin/structure/views/view/' . $random_view['id'] . '/duplicate', $view, t('Duplicate'));

  // Assert that the page url is correct.
  $this
    ->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');

  // Assert that the page title is correctly displayed.
  $this
    ->assertText($view['label']);
}