X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fredirect%2Ftests%2Fsrc%2FUnit%2FRedirectRequestSubscriberTest.php;fp=web%2Fmodules%2Fcontrib%2Fredirect%2Ftests%2Fsrc%2FUnit%2FRedirectRequestSubscriberTest.php;h=e664e95bab49756366a8dd9c1b893a3f5c9c534f;hp=4982bdb6e09ebc2c5e653bf3a32b34d03ee75163;hb=059867c3f96750652c80f39e44c442a58c2549ee;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2 diff --git a/web/modules/contrib/redirect/tests/src/Unit/RedirectRequestSubscriberTest.php b/web/modules/contrib/redirect/tests/src/Unit/RedirectRequestSubscriberTest.php index 4982bdb6e..e664e95ba 100644 --- a/web/modules/contrib/redirect/tests/src/Unit/RedirectRequestSubscriberTest.php +++ b/web/modules/contrib/redirect/tests/src/Unit/RedirectRequestSubscriberTest.php @@ -105,6 +105,7 @@ class RedirectRequestSubscriberTest extends UnitTestCase { return [ ['non-existing', ['key' => 'val'], '/test-path', ['dummy' => 'value']], ['non-existing/', ['key' => 'val'], '/test-path', ['dummy' => 'value']], + ['system/files/file.txt', [], '/test-path', []], ]; } @@ -134,9 +135,6 @@ class RedirectRequestSubscriberTest extends UnitTestCase { $checker->expects($this->any()) ->method('canRedirect') ->will($this->returnValue(TRUE)); - $checker->expects($this->any()) - ->method('isLoop') - ->will($this->returnValue(FALSE)); $context = $this->getMock('Symfony\Component\Routing\RequestContext'); @@ -146,7 +144,17 @@ class RedirectRequestSubscriberTest extends UnitTestCase { $inbound_path_processor->expects($this->any()) ->method('processInbound') ->with($request->getPathInfo(), $request) - ->will($this->returnValue($request->getPathInfo())); + ->willReturnCallback(function ($path, Request $request) { + if (strpos($path, '/system/files/') === 0 && !$request->query->has('file')) { + // Private files paths are split by the inbound path processor and the + // relative file path is moved to the 'file' query string parameter. + // This is because the route system does not allow an arbitrary amount + // of parameters. + // @see \Drupal\system\PathProcessor\PathProcessorFiles::processInbound() + $path = '/system/files'; + } + return $path; + }); $alias_manager = $this->getMockBuilder('Drupal\Core\Path\AliasManager') ->disableOriginalConstructor() @@ -189,9 +197,20 @@ class RedirectRequestSubscriberTest extends UnitTestCase { ->disableOriginalConstructor() ->getMock(); - $repository->expects($this->any()) - ->method($method) - ->will($this->returnValue($redirect)); + if ($method === 'findMatchingRedirect') { + $repository->expects($this->any()) + ->method($method) + ->willReturnCallback(function ($source_path) use ($redirect) { + // No redirect with source path 'system/files' exists. The stored + // redirect has 'system/files/file.txt' as source path. + return $source_path === 'system/files' ? NULL : $redirect; + }); + } + else { + $repository->expects($this->any()) + ->method($method) + ->will($this->returnValue($redirect)); + } return $repository; }