Commit 5a3027cb authored by alexpott's avatar alexpott
Browse files

Issue #2357925 by zaporylie | R. Volk: Fixed Duplicate view copies the old...

Issue #2357925 by zaporylie | R. Volk: Fixed Duplicate view copies the old view name and ignores the new one.
parent 058ca311
<?php
/**
* @file
* Contains \Drupal\views_ui\Tests\DuplicateTest.
*/
namespace Drupal\views_ui\Tests;
/**
* Tests the UI for view duplicate tool.
*
* @group views_ui
*/
class DuplicateTest extends UITestBase {
/**
* Checks if duplicated view exists and has correct label.
*/
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']);
}
}
......@@ -73,6 +73,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity = $this->entity->createDuplicate();
$this->entity->set('label', $form_state->getValue('label'));
$this->entity->set('id', $form_state->getValue('id'));
$this->entity->save();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment