Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
fix: VOL-4642 routing in olcs-transfer now sorted out, allowing tempo…
Browse files Browse the repository at this point in the history
…rary code to be removed. Code has been reset to how it was previously although tech debt ticket raised as the old code was itself a bit rubbish (#93)
  • Loading branch information
ilindsay authored Mar 7, 2024
1 parent 3a10b7f commit 5483fcd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
24 changes: 4 additions & 20 deletions module/Api/src/Mvc/PayloadValidationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,14 @@ public function onRoute(MvcEvent $e)
}

$dtoClass = $matches->getParam('dto', false);
$data = $matches->getParams();

/**
* there is an edge case, where Laminas route match is not bringing in the parameters correctly
* problem was introduced by:
* https://dvsa.atlassian.net/browse/VOL-3752
*
* Where this happens, we're able to get the params from the query parameters instead, as they seem unaffected
*
* The only query known to be broken is olcs-transfer/src/Query/Correspondence/Correspondences.php
*
* A ticket has been created for a more permanent fix for VOL-3752, and also mentions this issue:
* https://dvsa.atlassian.net/browse/VOL-4642
*/
if (!$dtoClass) {
$queryParams = $request->getQuery()->toArray();
$dtoClass = $queryParams['dto'] ?? false;

if (!$dtoClass) {
// no controller matched, nothing to do
return;
}
// no controller matched, nothing to do
return;
}

$data = $matches->getParams();

$dto = new $dtoClass();
$matches->setParam('dto', $dto);

Expand Down
2 changes: 0 additions & 2 deletions test/module/Api/src/Mvc/PayloadValidationListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ public function testOnRouteNoRouteMatch()
public function testOnRouteNoDtoClass()
{
$mockHttpRequest = m::mock(HttpRequest::class);
$mockHttpRequest->expects('getQuery->toArray')->withNoArgs()->andReturn([]);

$mockRouteMatch = m::mock(RouteMatch::class);
$mockRouteMatch->expects('getParams')->withNoArgs()->andReturn([]);
$mockRouteMatch->shouldReceive('getParam')
->with('dto', false)
->once()
Expand Down

0 comments on commit 5483fcd

Please sign in to comment.