DuplicateTest.php 1.14 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\views_ui\Functional;
4 5 6 7 8 9 10 11

/**
 * Tests the UI for view duplicate tool.
 *
 * @group views_ui
 */
class DuplicateTest extends UITestBase {

12 13
  protected function setUp($import_test_views = TRUE) {
    parent::setUp($import_test_views);
14

15
    $this->placeBlock('page_title_block');
16 17
  }

18 19 20 21 22 23 24 25 26
  /**
   * Checks if duplicated view exists and has correct label.
   */
  public function testDuplicateView() {

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

    // Initialize array for duplicated view.
27
    $view = [];
28 29 30 31 32 33 34 35 36

    // 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.
37
    $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
38 39 40 41

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

43
}