Commit 557bd088 authored by alexpott's avatar alexpott

Issue #2353347 by zaporylie, dawehner: Fixed Random failure in DisplayPathTest.

parent 4724ae1d
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\display;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
......@@ -450,6 +451,15 @@ protected function validatePath($path) {
$errors[] = $this->t('"%" may not be used for the first segment of a path.');
}
$parsed_url = UrlHelper::parse($path);
if (empty($parsed_url['path'])) {
$errors[] = $this->t('Path is empty.');
}
if (!empty($parsed_url['query'])) {
$errors[] = $this->t('No query allowed.');
}
$path_sections = explode('/', $path);
// Symfony routing does not allow to use numeric placeholders.
// @see \Symfony\Component\Routing\RouteCompiler
......
......@@ -92,8 +92,24 @@ public function testMenuOptions() {
// Add a new page display.
$this->drupalPostForm(NULL, array(), 'Add Page');
// Add an invalid path (only fragment).
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => '#foo'), t('Apply'));
$this->assertText('Path is empty');
// Add an invalid path with a query.
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => 'foo?bar'), t('Apply'));
$this->assertText('No query allowed.');
// Add an invalid path with just a query.
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => '?bar'), t('Apply'));
$this->assertText('Path is empty');
// Provide a random, valid path string.
$random_string = str_replace(['?', '#'], '_', $this->randomString());
// Save a path.
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => $this->randomString()), t('Apply'));
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => $random_string), t('Apply'));
$this->drupalGet('admin/structure/views/view/test_view');
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/menu', array('menu[type]' => 'default tab', 'menu[title]' => 'Test tab title'), t('Apply'));
......
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