Unverified Commit 422b3507 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3065720 by Lendude, alexpott, revati_gawas, texas-bronius: When...

Issue #3065720 by Lendude, alexpott, revati_gawas, texas-bronius: When creating a Page View in the wizard and setting a path with leading slash (/) the created View display ends up with a double-slash (//)

(cherry picked from commit 6ae9811c)
parent 5e387dcf
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -176,6 +176,20 @@ public function testViewsWizardAndListing() {
    $this->assertEqual(count($data), 1, 'Only the node of type page is exported.');
    $node = reset($data);
    $this->assertEqual($node['nid'][0]['value'], $node1->id(), 'The node of type page is exported.');

    // Create a view with a leading slash in the path and test that is properly
    // set.
    $leading_slash_view = [];
    $leading_slash_view['label'] = $this->randomMachineName(16);
    $leading_slash_view['id'] = strtolower($this->randomMachineName(16));
    $leading_slash_view['description'] = $this->randomMachineName(16);
    $leading_slash_view['show[wizard_key]'] = 'node';
    $leading_slash_view['show[type]'] = 'page';
    $leading_slash_view['page[create]'] = 1;
    $leading_slash_view['page[title]'] = $this->randomMachineName(16);
    $leading_slash_view['page[path]'] = '/' . $this->randomMachineName(16);
    $this->drupalPostForm('admin/structure/views/add', $leading_slash_view, t('Save and edit'));
    $this->assertEquals($leading_slash_view['page[path]'], $this->cssSelect('#views-page-1-path')[0]->getText());
  }

  /**
+7 −0
Original line number Diff line number Diff line
@@ -164,6 +164,13 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
    $wizard_instance = $this->wizardManager->createInstance($wizard_type);
    $form_state->set('wizard', $wizard_instance->getPluginDefinition());
    $form_state->set('wizard_instance', $wizard_instance);

    $path = &$form_state->getValue(['page', 'path']);
    if (!empty($path)) {
      // @todo https://www.drupal.org/node/2423913 Views should expect and store
      //   a leading /.
      $path = ltrim($path, '/ ');
    }
    $errors = $wizard_instance->validateView($form, $form_state);

    foreach ($errors as $display_errors) {