Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 2cf1797

Browse files
snapshotplweierophinney
authored andcommitted
Fixes after CR
1 parent 32e9b89 commit 2cf1797

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/Response.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ private function setStatusCode($code, $reasonPhrase = '')
175175
) {
176176
throw new InvalidArgumentException(sprintf(
177177
'Invalid status code "%s"; must be an integer between %d and %d, inclusive',
178-
(is_scalar($code) ? $code : gettype($code)),
178+
is_scalar($code) ? $code : gettype($code),
179179
static::MIN_STATUS_CODE_VALUE,
180180
static::MAX_STATUS_CODE_VALUE
181181
));
182182
}
183183

184184
if (! is_string($reasonPhrase)) {
185185
throw new InvalidArgumentException(sprintf(
186-
'Unsupported reason phrase; must be a string, received %s',
186+
'Unsupported response reason phrase; must be a string, received %s',
187187
is_object($reasonPhrase) ? get_class($reasonPhrase) : gettype($reasonPhrase)
188188
));
189189
}

test/ResponseTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,27 @@ public function testCanSetCustomReasonPhrase()
112112
$this->assertSame('Foo Bar!', $response->getReasonPhrase());
113113
}
114114

115-
public function testCannotCreateReasonPhraseNotString()
115+
public function invalidReasonPhrases()
116+
{
117+
return [
118+
'true' => [ true ],
119+
'false' => [ false ],
120+
'array' => [ [ 200 ] ],
121+
'object' => [ (object) [ 'reasonPhrase' => 'Ok' ] ],
122+
'integer' => [99],
123+
'float' => [400.5],
124+
'null' => [null],
125+
];
126+
}
127+
128+
/**
129+
* @dataProvider invalidReasonPhrases
130+
*/
131+
public function testWithStatusRaisesAnExceptionForNonStringReasonPhrases($invalidReasonPhrase)
116132
{
117133
$this->expectException(InvalidArgumentException::class);
118134

119-
$response = $this->response->withStatus(422, null);
135+
$this->response->withStatus(422, $invalidReasonPhrase);
120136
}
121137

122138
public function testConstructorRaisesExceptionForInvalidStream()

0 commit comments

Comments
 (0)