Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 9e1950b

Browse files
authored
Change type of statuses returned by getResponseCodes (#26)
* Change type of statuses returned by getResponseCodes * Update CHANGELOG * Remove allowance to failure on 7.2 on Travis
1 parent a2561c5 commit 9e1950b

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ matrix:
99
env:
1010
- EXECUTE_COVERAGE=true
1111
- php: 7.2
12-
allow_failures:
13-
- php: 7.2
1412

1513
notifications:
1614
email: false

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file
33
using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [0.4.0] 2018-12-01
7+
8+
### Fixed
9+
10+
- Change type of statuses returned by getResponseCodes from string to int
11+
12+
## [0.3.1] 2018-02-17
13+
14+
### Changed
15+
16+
- Add phpunit 6.0 fallback version
17+
618
## [0.3.0] 2018-02-17
719

820
### Changed

src/PhpUnit/Asserts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ final protected static function assertMethodAllowed(Spec $spec, $template, $meth
145145
final protected static function assertResponseDefined(Spec $spec, $template, $method, $status, $msg = '')
146146
{
147147
Assert::assertTrue(
148-
in_array((string) $status, $spec->getResponseCodes($template, strtolower($method)), true),
148+
in_array((int) $status, $spec->getResponseCodes($template, strtolower($method)), true),
149149
$msg ?: "Operation \"{$method} {$template}\" does not support response code \"{$status}\""
150150
);
151151
}

src/Schema.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,16 @@ public function getRequestContentTypes($template, $method)
217217
* @param string $template
218218
* @param string $method
219219
*
220-
* @return string[]
220+
* @return int[]
221221
*/
222222
public function getResponseCodes($template, $method)
223223
{
224-
return array_filter(
225-
array_keys((array) $this->fetch($this->schema, 'paths', $template, $method, 'responses')),
226-
'is_numeric'
224+
return array_map(
225+
'intval',
226+
array_filter(
227+
array_keys((array) $this->fetch($this->schema, 'paths', $template, $method, 'responses')),
228+
'is_numeric'
229+
)
227230
);
228231
}
229232

tests/SchemaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function howToUseSwagger(Schema $spec)
158158
$this->assertSame(['application/json'], $produces);
159159

160160
$statuses = $spec->getResponseCodes($template, 'get');
161-
$this->assertSame(['200'], $statuses);
161+
$this->assertSame([200], $statuses);
162162

163163
$responseHeaders = $spec->getResponseHeaderSchemas($template, 'get', 200);
164164
$this->assertTrue(isset($responseHeaders['Content-Type']));

0 commit comments

Comments
 (0)