Skip to content

Commit

Permalink
Fix php linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MishNajam committed Dec 7, 2023
1 parent 25900b4 commit aa6772b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
10 changes: 5 additions & 5 deletions service-front/app/src/Common/src/Handler/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ abstract public function handle(ServerRequestInterface $request): ResponseInterf

/**
* Handles a redirect to route
* localeOverride used to override from English to Welsh only
* $basePathOverride used to override from English to Welsh only
*
* @param $route
* @param $routeParams
* @param $queryParams
* @param string|null $localeOverride
* @param string|null $basePathOverride
* @return RedirectResponse
*/
public function redirectToRoute($route, $routeParams = [], $queryParams = [], ?string $localeOverride = null): RedirectResponse
public function redirectToRoute($route, $routeParams = [], $queryParams = [], ?string $basePathOverride = null): RedirectResponse
{
//TODO: UML-3203 Identify if OneLogin can handle multiple redirect urls, then remove
if ($localeOverride !== null) {
$this->urlHelper->setBasePath($localeOverride);
if ($basePathOverride !== null) {
$this->urlHelper->setBasePath($basePathOverride);
}
return new RedirectResponse($this->urlHelper->generate($route, $routeParams, $queryParams));
}
Expand Down
16 changes: 3 additions & 13 deletions service-front/app/test/CommonTest/Handler/AbstractHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,13 @@

namespace CommonTest\Handler;

use Common\Handler\AbstractHandler;
use Exception;
use CommonTest\Handler\TestableAbstractHandler;
use Mezzio\Helper\UrlHelper;
use Mezzio\Template\TemplateRendererInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

class TestableAbstractHandler extends AbstractHandler {
public function handle(ServerRequestInterface $request): ResponseInterface
{
throw new Exception('Not implemented');
}
}

class AbstractHandlerTest extends TestCase
{
Expand All @@ -44,7 +34,7 @@ public function testRedirectToRouteWithOverride(): void
$renderer = $this->prophesize(TemplateRendererInterface::class);

$abstractHandler = new TestableAbstractHandler($renderer->reveal(), $urlHelperMock->reveal());
$response = $abstractHandler->redirectToRoute(
$response = $abstractHandler->redirectToRoute(
'fake-route',
['fake-route-parameters'],
['fake-query-parameters'],
Expand All @@ -66,7 +56,7 @@ public function testRedirectToRouteOverrideSetToNull(): void
$renderer = $this->prophesize(TemplateRendererInterface::class);

$abstractHandler = new TestableAbstractHandler($renderer->reveal(), $urlHelperMock->reveal());
$response = $abstractHandler->redirectToRoute('fake-route');
$response = $abstractHandler->redirectToRoute('fake-route');
$this->assertEquals('/fake-route', $response->getHeader('location')[0]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace CommonTest\Handler;

use Common\Handler\AbstractHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

class TestableAbstractHandler extends AbstractHandler
{
public function handle(ServerRequestInterface $request): ResponseInterface
{
throw new Exception('Not implemented');
}
}

0 comments on commit aa6772b

Please sign in to comment.