Skip to content

Commit

Permalink
feat(404-prepartor): fix 404 generated path parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sidux committed May 16, 2024
1 parent 2482cfc commit f9e8807
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Preparator/Error404Preparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

final class Error404Preparator extends TestCasesPreparator
{
public const INT32_MAX = 2147483647;

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -40,10 +42,16 @@ private function prepareTestCase(DefinitionResponse $response): array

$testcases = [];

$pathParameters = $operation->getPathParameters()
->map(static fn ($parameter) => $parameter->getName())
->toArray()
;
$pathParameters = array_fill_keys($pathParameters, self::INT32_MAX);

if ($operation->getRequestBodies()->count() === 0) {
$testcases[] = $this->buildTestCase(
OperationExample::create('RandomPath', $operation)
->setForceRandom()
->setPathParameters($pathParameters)
->setResponse(
ResponseExample::create()
->setStatusCode($this->config->response->getStatusCode() ?? '404')
Expand All @@ -56,7 +64,7 @@ private function prepareTestCase(DefinitionResponse $response): array
foreach ($operation->getRequestBodies() as $ignored) {
$testcases[] = $this->buildTestCase(
OperationExample::create('RandomPath', $operation)
->setForceRandom()
->setPathParameters($pathParameters)
->setResponse(
ResponseExample::create()
->setStatusCode($this->config->response->getStatusCode() ?? '404')
Expand Down

0 comments on commit f9e8807

Please sign in to comment.