Skip to content
Snippets Groups Projects
Commit c1f9e7e7 authored by mondrake's avatar mondrake
Browse files

fix

parent c48a2ac2
No related branches found
No related tags found
No related merge requests found
Pipeline #107185 failed
......@@ -9,6 +9,7 @@
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Core\Utility\UnroutedUrlAssemblerInterface;
use Drupal\Tests\UnitTestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
......@@ -36,12 +37,21 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
*/
protected $urlAssembler;
/**
* The mocked logger closure.
*/
protected \Closure $loggerClosure;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->loggerClosure = function() {
$this->prophesize(LoggerInterface::class)->reveal();
}
$this->requestContext = $this->getMockBuilder('Drupal\Core\Routing\RequestContext')
->disableOriginalConstructor()
->getMock();
......@@ -82,7 +92,7 @@ public function testDestinationRedirect(Request $request, $expected) {
$response = new RedirectResponse('http://example.com/drupal');
$request->headers->set('HOST', 'example.com');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->prophesize(\Closure::class)->reveal());
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->loggerClosure);
$dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch($event, KernelEvents::RESPONSE);
......@@ -122,7 +132,7 @@ public function testDestinationRedirectToExternalUrl($request, $expected) {
$kernel = $this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$response = new RedirectResponse('http://other-example.com');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->prophesize(\Closure::class)->reveal());
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->loggerClosure);
$dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch($event, KernelEvents::RESPONSE);
......@@ -139,7 +149,7 @@ public function testRedirectWithOptInExternalUrl() {
$request = Request::create('');
$request->headers->set('HOST', 'example.com');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->prophesize(\Closure::class)->reveal());
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->loggerClosure);
$dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch($event, KernelEvents::RESPONSE);
......@@ -170,7 +180,7 @@ public function testDestinationRedirectWithInvalidUrl(Request $request) {
$kernel = $this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$response = new RedirectResponse('http://example.com/drupal');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->prophesize(\Closure::class)->reveal());
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext, $this->loggerClosure);
$dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch($event, KernelEvents::RESPONSE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment