From fd63394783316467f4bf81fa799c1b5ce9402997 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 18 Nov 2014 23:39:38 +0000 Subject: [PATCH] Issue #2345725 by tim.plunkett: Query parameters are not decoded the same as the path portion of a URL --- .../Tests/Core/Routing/UrlGeneratorTest.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index ff14dae1d3b..b3a044734be 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -230,6 +230,51 @@ class UrlGeneratorTest extends UnitTestCase { $this->assertEquals('test/two/5', $path); } + /** + * Confirms that generated routes will have aliased paths with options. + * + * @dataProvider providerTestAliasGenerationWithOptions + */ + public function testAliasGenerationWithOptions($route_name, $route_parameters, $options, $expected) { + $url = $this->generator->generateFromRoute($route_name, $route_parameters, $options); + $this->assertSame($expected, $url); + } + + /** + * Provides test data for testAliasGenerationWithOptions. + */ + public function providerTestAliasGenerationWithOptions() { + $data = []; + // Extra parameters should appear in the query string. + $data[] = [ + 'test_1', + ['zoo' => '5'], + ['fragment' => 'top'], + '/hello/world?zoo=5#top', + ]; + $data[] = [ + 'test_2', + ['narf' => '5'], + ['query' => ['page' => '1'], 'fragment' => 'bottom'], + '/goodbye/cruel/world?page=1#bottom', + ]; + // Changing the parameters, the route still matches but there is no alias. + $data[] = [ + 'test_2', + ['narf' => '7'], + ['query' => ['page' => '1'], 'fragment' => 'bottom'], + '/test/two/7?page=1#bottom', + ]; + // Query string values containing '/' should be decoded. + $data[] = [ + 'test_2', + ['narf' => '7'], + ['query' => ['page' => '1/2'], 'fragment' => 'bottom'], + '/test/two/7?page=1/2#bottom', + ]; + return $data; + } + /** * Tests URL generation from route with trailing start and end slashes. */