X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FCore%2FRouting%2FRequestFormatRouteFilterTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FTests%2FCore%2FRouting%2FRequestFormatRouteFilterTest.php;h=83d0505f15c765a2dbf3d4af011c2d2a9cb7ca81;hp=3574ee195004ca24718284846eefd19e9f4341c9;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/tests/Drupal/Tests/Core/Routing/RequestFormatRouteFilterTest.php b/web/core/tests/Drupal/Tests/Core/Routing/RequestFormatRouteFilterTest.php index 3574ee195..83d0505f1 100644 --- a/web/core/tests/Drupal/Tests/Core/Routing/RequestFormatRouteFilterTest.php +++ b/web/core/tests/Drupal/Tests/Core/Routing/RequestFormatRouteFilterTest.php @@ -2,7 +2,10 @@ namespace Drupal\Tests\Core\Routing; +use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\Core\GeneratedUrl; use Drupal\Core\Routing\RequestFormatRouteFilter; +use Drupal\Core\Utility\UnroutedUrlAssemblerInterface; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; @@ -59,6 +62,14 @@ class RequestFormatRouteFilterTest extends UnitTestCase { * @covers ::filter */ public function testNoRouteFound() { + $url = $this->prophesize(GeneratedUrl::class); + $url_assembler = $this->prophesize(UnroutedUrlAssemblerInterface::class); + $url_assembler->assemble('http://localhost/test?_format=xml', ['query' => ['_format' => 'json'], 'external' => TRUE], TRUE) + ->willReturn($url); + $container = new ContainerBuilder(); + $container->set('unrouted_url_assembler', $url_assembler->reveal()); + \Drupal::setContainer($container); + $collection = new RouteCollection(); $route_with_format = $route = new Route('/test'); $route_with_format->setRequirement('_format', 'json'); @@ -78,6 +89,16 @@ class RequestFormatRouteFilterTest extends UnitTestCase { public function testNoRouteFoundWhenNoRequestFormatAndSingleRouteWithMultipleFormats() { $this->setExpectedException(NotAcceptableHttpException::class, 'No route found for the specified format html.'); + $url = $this->prophesize(GeneratedUrl::class); + $url_assembler = $this->prophesize(UnroutedUrlAssemblerInterface::class); + $url_assembler->assemble('http://localhost/test', ['query' => ['_format' => 'json'], 'external' => TRUE], TRUE) + ->willReturn($url); + $url_assembler->assemble('http://localhost/test', ['query' => ['_format' => 'xml'], 'external' => TRUE], TRUE) + ->willReturn($url); + $container = new ContainerBuilder(); + $container->set('unrouted_url_assembler', $url_assembler->reveal()); + \Drupal::setContainer($container); + $collection = new RouteCollection(); $route_with_format = $route = new Route('/test'); $route_with_format->setRequirement('_format', 'json|xml');