Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Symfony 7 support #92

Merged
merged 18 commits into from
Jul 24, 2024
28 changes: 16 additions & 12 deletions Tests/Unit/Controller/RedirectControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ class RedirectControllerTest extends TestCase
*/
private $controller;

/**
* @var Request
*/
private $request;

/**
* @var InputBag|ParameterBag
*/
Expand All @@ -45,22 +40,22 @@ protected function setUp(): void
{
$this->controller = new WebsiteRedirectController();

$this->request = $this->prophesize(Request::class);
$this->queryBag = class_exists(InputBag::class) ? new InputBag() : new ParameterBag();
$this->redirectRoute = $this->prophesize(RedirectRouteInterface::class);

$this->request->reveal()->query = $this->queryBag;
}

public function testRedirect()
{
$target = '/test';
$statusCode = 301;

$request = Request::create($target);
$request->query = $this->queryBag;
TheCadien marked this conversation as resolved.
Show resolved Hide resolved

$this->redirectRoute->getTarget()->willReturn($target);
$this->redirectRoute->getStatusCode()->willReturn($statusCode);

$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());

$this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertEquals($target, $response->getTargetUrl());
Expand All @@ -75,10 +70,13 @@ public function testRedirectWithQuery()

$this->queryBag->add($query);

$request = Request::create($target);
$request->query = $this->queryBag;

$this->redirectRoute->getTarget()->willReturn($target);
$this->redirectRoute->getStatusCode()->willReturn($statusCode);

$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());

$this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertEquals(
Expand All @@ -93,10 +91,13 @@ public function testRedirectExternal()
$target = 'http://captain-sulu.io/test';
$statusCode = 301;

$request = Request::create($target);
$request->query = $this->queryBag;

$this->redirectRoute->getTarget()->willReturn($target);
$this->redirectRoute->getStatusCode()->willReturn($statusCode);

$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());

$this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertEquals(
Expand All @@ -114,10 +115,13 @@ public function testRedirectExternalWithQuery()

$this->queryBag->add($query);

$request = Request::create($target);
$request->query = $this->queryBag;

$this->redirectRoute->getTarget()->willReturn($target);
$this->redirectRoute->getStatusCode()->willReturn($statusCode);

$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());

$this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertEquals(
Expand Down
13 changes: 1 addition & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,6 @@ parameters:
count: 4
path: Tests/Unit/Controller/RedirectControllerTest.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpFoundation\\\\Request\\:\\:reveal\\(\\)\\.$#"
count: 4
path: Tests/Unit/Controller/RedirectControllerTest.php


-
message: "#^Cannot call method willReturn\\(\\) on int\\.$#"
count: 4
Expand Down Expand Up @@ -361,14 +355,9 @@ parameters:
count: 1
path: Tests/Unit/Controller/RedirectControllerTest.php

-
message: "#^Property Sulu\\\\Bundle\\\\RedirectBundle\\\\Tests\\\\Unit\\\\Controller\\\\RedirectControllerTest\\:\\:\\$request \\(Symfony\\\\Component\\\\HttpFoundation\\\\Request\\) does not accept Prophecy\\\\Prophecy\\\\ObjectProphecy\\<Symfony\\\\Component\\\\HttpFoundation\\\\Request\\>\\.$#"
count: 1
path: Tests/Unit/Controller/RedirectControllerTest.php

-
message: "#^Property Symfony\\\\Component\\\\HttpFoundation\\\\Request\\:\\:\\$query \\(Symfony\\\\Component\\\\HttpFoundation\\\\InputBag\\<string\\>\\) does not accept Symfony\\\\Component\\\\HttpFoundation\\\\ParameterBag\\.$#"
count: 1
count: 4
path: Tests/Unit/Controller/RedirectControllerTest.php

-
Expand Down
Loading