Skip to content

Commit

Permalink
Fix Transformer status code type
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jun 8, 2021
1 parent c9b34a5 commit badae47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Extracting/Strategies/Responses/UseTransformerTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function getStatusCodeAndTransformerClass($tag): array
{
$content = $tag->getContent();
preg_match('/^(\d{3})?\s?([\s\S]*)$/', $content, $result);
$status = $result[1] ?: 200;
$status = (int)($result[1] ?: 200);
$transformerClass = $result[2];

return [$status, $transformerClass];
Expand Down
4 changes: 2 additions & 2 deletions tests/Strategies/Responses/UseApiResourceTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ public function can_parse_apiresource_tags_with_model_factory_states()

$strategy = new UseApiResourceTags($config);
$tags = [
new Tag('apiResource', '\Knuckles\Scribe\Tests\Fixtures\TestUserApiResource'),
new Tag('apiResource', '201 \Knuckles\Scribe\Tests\Fixtures\TestUserApiResource'),
new Tag('apiResourceModel', '\Knuckles\Scribe\Tests\Fixtures\TestUser states=state1,random-state'),
];
$results = $strategy->getApiResourceResponse($strategy->getApiResourceTag($tags), $tags, ExtractedEndpointData::fromRoute($route));

$this->assertArraySubset([
[
'status' => 200,
'status' => 201,
'content' => json_encode([
'data' => [
'id' => 4,
Expand Down

0 comments on commit badae47

Please sign in to comment.