-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* UML-3106 Implement One Login callback handler on service-front * Refactor switch statement to match * add behat testing for access denied and temp unavailable errors * add generic error behat tests * Can redirect in Welsh * Replace assertObjectHasAttributes with assertObjectHasProperty * Callback method passes code, state, authsession, abstracthandler passes basepath * add PR fixes * replace testableAbstractHandler with an anoymous class
- Loading branch information
Showing
13 changed files
with
297 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
service-front/app/test/CommonTest/Handler/AbstractHandlerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CommonTest\Handler; | ||
|
||
use Common\Handler\AbstractHandler; | ||
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 AbstractHandlerTest extends TestCase | ||
{ | ||
use ProphecyTrait; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function testRedirectToRouteWithOverride(): void | ||
{ | ||
$localOverride = 'cy'; | ||
/** @var UrlHelper|ObjectProphecy $urlHelperMock */ | ||
$urlHelperMock = $this->prophesize(UrlHelper::class); | ||
$urlHelperMock->setBasePath($localOverride)->shouldBeCalledOnce(); | ||
$urlHelperMock->generate( | ||
'fake-route', | ||
['fake-route-parameters'], | ||
['fake-query-parameters'], | ||
)->willReturn('/cy/fake-route'); | ||
|
||
$renderer = $this->prophesize(TemplateRendererInterface::class); | ||
|
||
$abstractHandler = new class ($renderer->reveal(), $urlHelperMock->reveal()) extends AbstractHandler { | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
throw new Exception('Not implemented'); | ||
} | ||
}; | ||
$response = $abstractHandler->redirectToRoute( | ||
'fake-route', | ||
['fake-route-parameters'], | ||
['fake-query-parameters'], | ||
$localOverride, | ||
); | ||
$this->assertEquals('/cy/fake-route', $response->getHeader('location')[0]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function testRedirectToRouteOverrideSetToNull(): void | ||
{ | ||
/** @var UrlHelper|ObjectProphecy $urlHelperMock */ | ||
$urlHelperMock = $this->prophesize(UrlHelper::class); | ||
$urlHelperMock->setBasePath(Argument::any())->shouldNotBeCalled(); | ||
$urlHelperMock->generate('fake-route', [], [])->willReturn('/fake-route'); | ||
|
||
$renderer = $this->prophesize(TemplateRendererInterface::class); | ||
|
||
$abstractHandler = new class ($renderer->reveal(), $urlHelperMock->reveal()) extends AbstractHandler { | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
throw new Exception('Not implemented'); | ||
} | ||
}; | ||
$response = $abstractHandler->redirectToRoute('fake-route'); | ||
$this->assertEquals('/fake-route', $response->getHeader('location')[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.