diff --git a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php index e13b85b..1359d47 100644 --- a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php @@ -111,8 +111,8 @@ public function providerTestAssembleWithExternalUrl() { * * @dataProvider providerTestAssembleWithLocalUri */ - public function testAssembleWithLocalUri($uri, array $options, $subdir, $expected) { - $this->setupRequestStack($subdir); + public function testAssembleWithLocalUri($uri, array $options, $subdir, $script_path, $expected) { + $this->setupRequestStack($subdir, $script_path); $this->assertEquals($expected, $this->unroutedUrlAssembler->assemble($uri, $options)); } @@ -122,18 +122,22 @@ public function testAssembleWithLocalUri($uri, array $options, $subdir, $expecte */ public function providerTestAssembleWithLocalUri() { return [ - ['base:example', [], FALSE, '/example'], - ['base:example', ['query' => ['foo' => 'bar']], FALSE, '/example?foo=bar'], - ['base:example', ['query' => ['foo' => '"bar"']], FALSE, '/example?foo=%22bar%22'], - ['base:example', ['query' => ['foo' => '"bar"', 'zoo' => 'baz']], FALSE, '/example?foo=%22bar%22&zoo=baz'], - ['base:example', ['fragment' => 'example', ], FALSE, '/example#example'], - ['base:example', [], TRUE, '/subdir/example'], - ['base:example', ['query' => ['foo' => 'bar']], TRUE, '/subdir/example?foo=bar'], - ['base:example', ['fragment' => 'example', ], TRUE, '/subdir/example#example'], - ['base:/drupal.org', [], FALSE, '/drupal.org'], + ['base:example', [], FALSE, '', '/example'], + ['base:example', ['query' => ['foo' => 'bar']], FALSE, '', '/example?foo=bar'], + ['base:example', ['query' => ['foo' => '"bar"']], FALSE, '', '/example?foo=%22bar%22'], + ['base:example', ['query' => ['foo' => '"bar"', 'zoo' => 'baz']], FALSE, '', '/example?foo=%22bar%22&zoo=baz'], + ['base:example', ['fragment' => 'example', ], FALSE, '', '/example#example'], + ['base:example', [], TRUE, '', '/subdir/example'], + ['base:example', ['query' => ['foo' => 'bar']], TRUE, '', '/subdir/example?foo=bar'], + ['base:example', ['fragment' => 'example', ], TRUE, '', '/subdir/example#example'], + ['base:/bar/foo.php', ['script' => 'foo.php/'], TRUE, '', '/subdir/bar/foo.php'], + ['base:/bar/foo.php', ['script' => 'foo.php/'], FALSE, '', '/bar/foo.php'], + ['base:/drupal.org', [], FALSE, '', '/drupal.org'], + ['base:core/authorize.php', [], FALSE, 'core/authorize.php', '/core/authorize.php'], ]; } + /** * @covers ::assemble */ @@ -174,25 +178,31 @@ public function testAssembleWithEnabledProcessing() { * * @param string $subdir * The wanted subdir. + * @param string $script_path + * Path to the script, e.g. 'index.php' or 'core/authorize.php'. */ - protected function setupRequestStack($subdir) { + protected function setupRequestStack($subdir, $script_path = "") { $server = []; if ($subdir) { + if (empty($script_path)) { + $script_path = "index.php"; + } // Setup a fake request which looks like a Drupal installed under the // subdir "subdir" on the domain www.example.com. // To reproduce the values install Drupal like that and use a debugger. $server = [ - 'SCRIPT_NAME' => '/subdir/index.php', - 'SCRIPT_FILENAME' => $this->root . '/index.php', + 'SCRIPT_NAME' => '/subdir/' . $script_path, + 'SCRIPT_FILENAME' => $this->root . '/' . $script_path, 'SERVER_NAME' => 'http://www.example.com', ]; $request = Request::create('/subdir/'); } else { - $request = Request::create('/'); + $request = Request::create('/' . $script_path); } $request->server->add($server); $this->requestStack->push($request); } } +