diff --git a/Classes/Utility/PluginUtility.php b/Classes/Utility/PluginUtility.php new file mode 100644 index 00000000..9cc4e7bd --- /dev/null +++ b/Classes/Utility/PluginUtility.php @@ -0,0 +1,29 @@ + $this->urlUtility->withRequest($request)->prepareRelativeUrlIfPossible($uri), + 'statusCode' => $statusCode, + ])); + } +} diff --git a/Tests/Unit/Utility/PluginUtilityTest.php b/Tests/Unit/Utility/PluginUtilityTest.php new file mode 100644 index 00000000..6bb89448 --- /dev/null +++ b/Tests/Unit/Utility/PluginUtilityTest.php @@ -0,0 +1,50 @@ +createMock(Resolver::class), $this->createMock(SiteFinder::class)); + + $pluginRedirect = new PluginUtility($urlUtility); + + $this->expectException(PropagateResponseException::class); + + $pluginRedirect->redirect(new ServerRequest(), '/test'); + } + + public function testResponse(): void + { + $urlUtility = new UrlUtility(new Features(), $this->createMock(Resolver::class), $this->createMock(SiteFinder::class)); + + $pluginRedirect = new PluginUtility($urlUtility); + + try { + $pluginRedirect->redirect(new ServerRequest(), '/test'); + } catch (PropagateResponseException $exception) { + self::assertSame(['redirectUrl' => '/test', 'statusCode' => 307], json_decode($exception->getResponse()->getBody()->getContents(), true)); + } + } +}