This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -175,15 +175,15 @@ private function setStatusCode($code, $reasonPhrase = '')
175
175
) {
176
176
throw new InvalidArgumentException (sprintf (
177
177
'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 ),
179
179
static ::MIN_STATUS_CODE_VALUE ,
180
180
static ::MAX_STATUS_CODE_VALUE
181
181
));
182
182
}
183
183
184
184
if (! is_string ($ reasonPhrase )) {
185
185
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 ' ,
187
187
is_object ($ reasonPhrase ) ? get_class ($ reasonPhrase ) : gettype ($ reasonPhrase )
188
188
));
189
189
}
Original file line number Diff line number Diff line change @@ -112,11 +112,27 @@ public function testCanSetCustomReasonPhrase()
112
112
$ this ->assertSame ('Foo Bar! ' , $ response ->getReasonPhrase ());
113
113
}
114
114
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 )
116
132
{
117
133
$ this ->expectException (InvalidArgumentException::class);
118
134
119
- $ response = $ this ->response ->withStatus (422 , null );
135
+ $ this ->response ->withStatus (422 , $ invalidReasonPhrase );
120
136
}
121
137
122
138
public function testConstructorRaisesExceptionForInvalidStream ()
You can’t perform that action at this time.
0 commit comments