Skip to content

Commit

Permalink
Tests: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 13, 2022
1 parent 8175e73 commit feeb2d8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/Cases/Core/Mapping/RequestEntityMapping.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,22 @@ test(function (): void {
$request = new ApiRequest(Psr7ServerRequestFactory::fromSuperGlobal());
$entity = new NotEmptyEntity();

$queryRequest = $request
->withQueryParams(['foo' => 1]);

$bodyRequest = $request
->withBody(Utils::streamFor(json_encode(['foo' => 1])));

foreach ([Endpoint::METHOD_GET, Endpoint::METHOD_DELETE, Endpoint::METHOD_HEAD] as $method) {
$entity = $entity->fromRequest($queryRequest->withMethod($method));
$queryRequest = $request
->withQueryParams(['foo' => 1])
->withMethod($method);

$entity = $entity->fromRequest($queryRequest);

Assert::same(1, $entity->foo);
}

foreach ([Endpoint::METHOD_POST, Endpoint::METHOD_PUT, Endpoint::METHOD_PATCH] as $method) {
$entity = $entity->fromRequest($bodyRequest->withMethod($method));
$bodyRequest = $request
->withBody(Utils::streamFor(json_encode(['foo' => 1])))
->withMethod($method);

$entity = $entity->fromRequest($bodyRequest);

Assert::same(1, $entity->foo);
}
Expand Down

0 comments on commit feeb2d8

Please sign in to comment.