1 | <?php |
||
12 | final class StringsTest extends TestCase |
||
13 | { |
||
14 | /** |
||
15 | * Verify bahavior of format() with argument cannot be casted to a string. |
||
16 | * |
||
17 | * @test |
||
18 | * @expectedException TypeError |
||
19 | * @covers ::format |
||
20 | * |
||
21 | * @return void |
||
22 | */ |
||
23 | public function formatNonStringCastableObject() |
||
27 | |||
28 | /** |
||
29 | * Verify bahavior of format() with object argument casted to a string. |
||
30 | * |
||
31 | * @test |
||
32 | * @covers ::format |
||
33 | * |
||
34 | * @return void |
||
35 | */ |
||
36 | public function formatStringCastableObject() |
||
44 | |||
45 | /** |
||
46 | * Verify bahavior of format() with repeated key. |
||
47 | * |
||
48 | * @test |
||
49 | * @covers ::format |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function formatKeysAreRepeatable() |
||
57 | |||
58 | /** |
||
59 | * Verify bahavior of format() with repeated unordered keys. |
||
60 | * |
||
61 | * @test |
||
62 | * @covers ::format |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function formatKeyOrderDoesNotMatter() |
||
70 | |||
71 | /** |
||
72 | * Verify bahavior of format() with non-string $format. |
||
73 | * |
||
74 | * @test |
||
75 | * @expectedException TypeError |
||
76 | * @covers ::format |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | public function formatNonStringFormat() |
||
84 | |||
85 | /** |
||
86 | * @test |
||
87 | * @covers ::endsWith |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | public function endsWithEmptyString() |
||
97 | |||
98 | /** |
||
99 | * Verify matching bahavior of endsWith(). |
||
100 | * |
||
101 | * @test |
||
102 | * @covers ::endsWith |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | public function endsWithMatches() |
||
112 | |||
113 | /** |
||
114 | * Verify non-matching bahavior of endsWith(). |
||
115 | * |
||
116 | * @test |
||
117 | * @covers ::endsWith |
||
118 | * |
||
119 | * @return void |
||
120 | */ |
||
121 | public function endsWithNoMatches() |
||
127 | |||
128 | /** |
||
129 | * Verify non-matching bahavior of endsWith(). |
||
130 | * |
||
131 | * @test |
||
132 | * @expectedException TypeError |
||
133 | * @covers ::endsWith |
||
134 | * |
||
135 | * @return void |
||
136 | */ |
||
137 | public function endsWithBadTypeForSubject() |
||
141 | |||
142 | /** |
||
143 | * Verify behavior of endsWith() with non-string $suffix. |
||
144 | * |
||
145 | * @test |
||
146 | * @expectedException TypeError |
||
147 | * @covers ::endsWith |
||
148 | * |
||
149 | * @return void |
||
150 | */ |
||
151 | public function endsWithBadTypeForSuffix() |
||
155 | |||
156 | /** |
||
157 | * Verify behavior of endsWith() with all arguments as empty strings. |
||
158 | * |
||
159 | * @test |
||
160 | * @covers ::endsWith |
||
161 | * |
||
162 | * @return void |
||
163 | */ |
||
164 | public function endsWithEmptyBoth() |
||
170 | |||
171 | /** |
||
172 | * Verify behavior of endsWith() with empty string $suffix. |
||
173 | * |
||
174 | * @test |
||
175 | * @covers ::endsWith |
||
176 | * |
||
177 | * @return void |
||
178 | */ |
||
179 | public function endsWithEmptySuffix() |
||
185 | |||
186 | /** |
||
187 | * Verify behavior of endsWith() with empty string $subject. |
||
188 | * |
||
189 | * @test |
||
190 | * @covers ::endsWith |
||
191 | * |
||
192 | * @return void |
||
193 | */ |
||
194 | public function endsWithEmptySubject() |
||
200 | |||
201 | /** |
||
202 | * Verify basic behavior of ellipsize(). |
||
203 | * |
||
204 | * @test |
||
205 | * @covers ::ellipsize |
||
206 | * |
||
207 | * @return void |
||
208 | */ |
||
209 | public function ellipsize() |
||
223 | |||
224 | /** |
||
225 | * Verify behavior of ellipsize() with negative max length. |
||
226 | * |
||
227 | * @test |
||
228 | * @covers ::ellipsize |
||
229 | * |
||
230 | * @return void |
||
231 | * @expectedException InvalidArgumentException |
||
232 | * @expectedExceptionMessage $maxLength is negative |
||
233 | */ |
||
234 | public function ellipsizeNegativeMaxLength() |
||
238 | |||
239 | /** |
||
240 | * Tests that ellipsize works with a custom suffix. |
||
241 | * |
||
242 | * @test |
||
243 | * @covers ::ellipsize |
||
244 | * |
||
245 | * @return void |
||
246 | */ |
||
247 | public function ellipsizeCustomSuffix() |
||
251 | |||
252 | /** |
||
253 | * Tests that ellipsize fails with an integer instead of a string. |
||
254 | * |
||
255 | * @test |
||
256 | * @expectedException TypeError |
||
257 | * @covers ::ellipsize |
||
258 | * |
||
259 | * @return void |
||
260 | */ |
||
261 | public function ellipsizeIntegerInsteadOfString() |
||
265 | |||
266 | /** |
||
267 | * Tests that ellipsize fails with a string for $maxLength. |
||
268 | * |
||
269 | * @test |
||
270 | * @expectedException TypeError |
||
271 | * @covers ::ellipsize |
||
272 | * |
||
273 | * @return void |
||
274 | */ |
||
275 | public function ellipsizeStringMaxLength() |
||
279 | |||
280 | /** |
||
281 | * @test |
||
282 | * @expectedException TypeError |
||
283 | * @covers ::ellipsize |
||
284 | * |
||
285 | * @return void |
||
286 | */ |
||
287 | public function ellipsizeNonStringSuffix() |
||
291 | |||
292 | /** |
||
293 | * Verify basic behavior of ucwords(). |
||
294 | * |
||
295 | * @test |
||
296 | * @covers ::ucwords |
||
297 | * |
||
298 | * @return void |
||
299 | */ |
||
300 | public function ucwords() |
||
305 | |||
306 | /** |
||
307 | * Verify behavior of ucwords() with optional delimiters. |
||
308 | * |
||
309 | * @test |
||
310 | * @covers ::ucwords |
||
311 | * |
||
312 | * @return void |
||
313 | */ |
||
314 | public function ucwordsOptionalDelimiters() |
||
319 | |||
320 | /** |
||
321 | * @test |
||
322 | * @covers ::ucwords |
||
323 | * |
||
324 | * @return void |
||
325 | */ |
||
326 | public function ucwordsNoDelimiters() |
||
331 | |||
332 | /** |
||
333 | * Verify behavior of ucwords() with single delimiter. |
||
334 | * |
||
335 | * @test |
||
336 | * @covers ::ucwords |
||
337 | * |
||
338 | * @return void |
||
339 | */ |
||
340 | public function ucwordsSingleDelimiter() |
||
345 | |||
346 | /** |
||
347 | * Verify behavior of ucwords() with non-string $string. |
||
348 | * |
||
349 | * @test |
||
350 | * @expectedException TypeError |
||
351 | * @covers ::ucwords |
||
352 | * |
||
353 | * @return void |
||
354 | */ |
||
355 | public function ucwordsBadTypeString() |
||
359 | |||
360 | /** |
||
361 | * Verify behavior of ucwords() with non-string $delimiters. |
||
362 | * |
||
363 | * @test |
||
364 | * @expectedException TypeError |
||
365 | * @covers ::ucwords |
||
366 | * |
||
367 | * @return void |
||
368 | */ |
||
369 | public function ucwordsBadTypeDelimiters() |
||
373 | } |
||
374 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: