Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 47
CRAP
0.00% covered (danger)
0.00%
0 / 73
PolyfillAssertTrait
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 47
3422
0.00% covered (danger)
0.00%
0 / 73
 assertEqualsWithDelta
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertContainsEquals
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertNotContainsEquals
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertIsArray
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsBool
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsFloat
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsInt
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsNumeric
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsObject
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsResource
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsString
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsScalar
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsCallable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsIterable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertStringContainsString
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertStringContainsStringIgnoringCase
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertStringNotContainsString
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertStringNotContainsStringIgnoringCase
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertFinite
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertInfinite
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertNan
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertIsReadable
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertNotIsReadable
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertIsNotReadable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertIsWritable
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertNotIsWritable
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertIsNotWritable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertDirectoryExists
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertDirectoryNotExists
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertDirectoryDoesNotExist
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertDirectoryIsReadable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertDirectoryNotIsReadable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertDirectoryIsNotReadable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertDirectoryIsWritable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertDirectoryNotIsWritable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertDirectoryIsNotWritable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertFileExists
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertFileNotExists
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 assertFileDoesNotExist
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertFileIsReadable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertFileNotIsReadable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertFileIsNotReadable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertFileIsWritable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertFileNotIsWritable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 assertFileIsNotWritable
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertMatchesRegularExpression
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 assertDoesNotMatchRegularExpression
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Bridge\PhpUnit\Legacy;
13
14use PHPUnit\Framework\Constraint\IsEqual;
15use PHPUnit\Framework\Constraint\LogicalNot;
16use PHPUnit\Framework\Constraint\StringContains;
17use PHPUnit\Framework\Constraint\TraversableContains;
18
19/**
20 * This trait is @internal.
21 */
22trait PolyfillAssertTrait
23{
24    /**
25     * @param float  $delta
26     * @param string $message
27     *
28     * @return void
29     */
30    public static function assertEqualsWithDelta($expected, $actual, $delta, $message = '')
31    {
32        $constraint = new IsEqual($expected, $delta);
33        static::assertThat($actual, $constraint, $message);
34    }
35
36    /**
37     * @param iterable $haystack
38     * @param string   $message
39     *
40     * @return void
41     */
42    public static function assertContainsEquals($needle, $haystack, $message = '')
43    {
44        $constraint = new TraversableContains($needle, false, false);
45        static::assertThat($haystack, $constraint, $message);
46    }
47
48    /**
49     * @param iterable $haystack
50     * @param string   $message
51     *
52     * @return void
53     */
54    public static function assertNotContainsEquals($needle, $haystack, $message = '')
55    {
56        $constraint = new LogicalNot(new TraversableContains($needle, false, false));
57        static::assertThat($haystack, $constraint, $message);
58    }
59
60    /**
61     * @param string $message
62     *
63     * @return void
64     */
65    public static function assertIsArray($actual, $message = '')
66    {
67        static::assertInternalType('array', $actual, $message);
68    }
69
70    /**
71     * @param string $message
72     *
73     * @return void
74     */
75    public static function assertIsBool($actual, $message = '')
76    {
77        static::assertInternalType('bool', $actual, $message);
78    }
79
80    /**
81     * @param string $message
82     *
83     * @return void
84     */
85    public static function assertIsFloat($actual, $message = '')
86    {
87        static::assertInternalType('float', $actual, $message);
88    }
89
90    /**
91     * @param string $message
92     *
93     * @return void
94     */
95    public static function assertIsInt($actual, $message = '')
96    {
97        static::assertInternalType('int', $actual, $message);
98    }
99
100    /**
101     * @param string $message
102     *
103     * @return void
104     */
105    public static function assertIsNumeric($actual, $message = '')
106    {
107        static::assertInternalType('numeric', $actual, $message);
108    }
109
110    /**
111     * @param string $message
112     *
113     * @return void
114     */
115    public static function assertIsObject($actual, $message = '')
116    {
117        static::assertInternalType('object', $actual, $message);
118    }
119
120    /**
121     * @param string $message
122     *
123     * @return void
124     */
125    public static function assertIsResource($actual, $message = '')
126    {
127        static::assertInternalType('resource', $actual, $message);
128    }
129
130    /**
131     * @param string $message
132     *
133     * @return void
134     */
135    public static function assertIsString($actual, $message = '')
136    {
137        static::assertInternalType('string', $actual, $message);
138    }
139
140    /**
141     * @param string $message
142     *
143     * @return void
144     */
145    public static function assertIsScalar($actual, $message = '')
146    {
147        static::assertInternalType('scalar', $actual, $message);
148    }
149
150    /**
151     * @param string $message
152     *
153     * @return void
154     */
155    public static function assertIsCallable($actual, $message = '')
156    {
157        static::assertInternalType('callable', $actual, $message);
158    }
159
160    /**
161     * @param string $message
162     *
163     * @return void
164     */
165    public static function assertIsIterable($actual, $message = '')
166    {
167        static::assertInternalType('iterable', $actual, $message);
168    }
169
170    /**
171     * @param string $needle
172     * @param string $haystack
173     * @param string $message
174     *
175     * @return void
176     */
177    public static function assertStringContainsString($needle, $haystack, $message = '')
178    {
179        $constraint = new StringContains($needle, false);
180        static::assertThat($haystack, $constraint, $message);
181    }
182
183    /**
184     * @param string $needle
185     * @param string $haystack
186     * @param string $message
187     *
188     * @return void
189     */
190    public static function assertStringContainsStringIgnoringCase($needle, $haystack, $message = '')
191    {
192        $constraint = new StringContains($needle, true);
193        static::assertThat($haystack, $constraint, $message);
194    }
195
196    /**
197     * @param string $needle
198     * @param string $haystack
199     * @param string $message
200     *
201     * @return void
202     */
203    public static function assertStringNotContainsString($needle, $haystack, $message = '')
204    {
205        $constraint = new LogicalNot(new StringContains($needle, false));
206        static::assertThat($haystack, $constraint, $message);
207    }
208
209    /**
210     * @param string $needle
211     * @param string $haystack
212     * @param string $message
213     *
214     * @return void
215     */
216    public static function assertStringNotContainsStringIgnoringCase($needle, $haystack, $message = '')
217    {
218        $constraint = new LogicalNot(new StringContains($needle, true));
219        static::assertThat($haystack, $constraint, $message);
220    }
221
222    /**
223     * @param string $message
224     *
225     * @return void
226     */
227    public static function assertFinite($actual, $message = '')
228    {
229        static::assertInternalType('float', $actual, $message);
230        static::assertTrue(is_finite($actual), $message ?: "Failed asserting that $actual is finite.");
231    }
232
233    /**
234     * @param string $message
235     *
236     * @return void
237     */
238    public static function assertInfinite($actual, $message = '')
239    {
240        static::assertInternalType('float', $actual, $message);
241        static::assertTrue(is_infinite($actual), $message ?: "Failed asserting that $actual is infinite.");
242    }
243
244    /**
245     * @param string $message
246     *
247     * @return void
248     */
249    public static function assertNan($actual, $message = '')
250    {
251        static::assertInternalType('float', $actual, $message);
252        static::assertTrue(is_nan($actual), $message ?: "Failed asserting that $actual is nan.");
253    }
254
255    /**
256     * @param string $filename
257     * @param string $message
258     *
259     * @return void
260     */
261    public static function assertIsReadable($filename, $message = '')
262    {
263        static::assertInternalType('string', $filename, $message);
264        static::assertTrue(is_readable($filename), $message ?: "Failed asserting that $filename is readable.");
265    }
266
267    /**
268     * @param string $filename
269     * @param string $message
270     *
271     * @return void
272     */
273    public static function assertNotIsReadable($filename, $message = '')
274    {
275        static::assertInternalType('string', $filename, $message);
276        static::assertFalse(is_readable($filename), $message ?: "Failed asserting that $filename is not readable.");
277    }
278
279    /**
280     * @param string $filename
281     * @param string $message
282     *
283     * @return void
284     */
285    public static function assertIsNotReadable($filename, $message = '')
286    {
287        static::assertNotIsReadable($filename, $message);
288    }
289
290    /**
291     * @param string $filename
292     * @param string $message
293     *
294     * @return void
295     */
296    public static function assertIsWritable($filename, $message = '')
297    {
298        static::assertInternalType('string', $filename, $message);
299        static::assertTrue(is_writable($filename), $message ?: "Failed asserting that $filename is writable.");
300    }
301
302    /**
303     * @param string $filename
304     * @param string $message
305     *
306     * @return void
307     */
308    public static function assertNotIsWritable($filename, $message = '')
309    {
310        static::assertInternalType('string', $filename, $message);
311        static::assertFalse(is_writable($filename), $message ?: "Failed asserting that $filename is not writable.");
312    }
313
314    /**
315     * @param string $filename
316     * @param string $message
317     *
318     * @return void
319     */
320    public static function assertIsNotWritable($filename, $message = '')
321    {
322        static::assertNotIsWritable($filename, $message);
323    }
324
325    /**
326     * @param string $directory
327     * @param string $message
328     *
329     * @return void
330     */
331    public static function assertDirectoryExists($directory, $message = '')
332    {
333        static::assertInternalType('string', $directory, $message);
334        static::assertTrue(is_dir($directory), $message ?: "Failed asserting that $directory exists.");
335    }
336
337    /**
338     * @param string $directory
339     * @param string $message
340     *
341     * @return void
342     */
343    public static function assertDirectoryNotExists($directory, $message = '')
344    {
345        static::assertInternalType('string', $directory, $message);
346        static::assertFalse(is_dir($directory), $message ?: "Failed asserting that $directory does not exist.");
347    }
348
349    /**
350     * @param string $directory
351     * @param string $message
352     *
353     * @return void
354     */
355    public static function assertDirectoryDoesNotExist($directory, $message = '')
356    {
357        static::assertDirectoryNotExists($directory, $message);
358    }
359
360    /**
361     * @param string $directory
362     * @param string $message
363     *
364     * @return void
365     */
366    public static function assertDirectoryIsReadable($directory, $message = '')
367    {
368        static::assertDirectoryExists($directory, $message);
369        static::assertIsReadable($directory, $message);
370    }
371
372    /**
373     * @param string $directory
374     * @param string $message
375     *
376     * @return void
377     */
378    public static function assertDirectoryNotIsReadable($directory, $message = '')
379    {
380        static::assertDirectoryExists($directory, $message);
381        static::assertNotIsReadable($directory, $message);
382    }
383
384    /**
385     * @param string $directory
386     * @param string $message
387     *
388     * @return void
389     */
390    public static function assertDirectoryIsNotReadable($directory, $message = '')
391    {
392        static::assertDirectoryNotIsReadable($directory, $message);
393    }
394
395    /**
396     * @param string $directory
397     * @param string $message
398     *
399     * @return void
400     */
401    public static function assertDirectoryIsWritable($directory, $message = '')
402    {
403        static::assertDirectoryExists($directory, $message);
404        static::assertIsWritable($directory, $message);
405    }
406
407    /**
408     * @param string $directory
409     * @param string $message
410     *
411     * @return void
412     */
413    public static function assertDirectoryNotIsWritable($directory, $message = '')
414    {
415        static::assertDirectoryExists($directory, $message);
416        static::assertNotIsWritable($directory, $message);
417    }
418
419    /**
420     * @param string $directory
421     * @param string $message
422     *
423     * @return void
424     */
425    public static function assertDirectoryIsNotWritable($directory, $message = '')
426    {
427        static::assertDirectoryNotIsWritable($directory, $message);
428    }
429
430    /**
431     * @param string $filename
432     * @param string $message
433     *
434     * @return void
435     */
436    public static function assertFileExists($filename, $message = '')
437    {
438        static::assertInternalType('string', $filename, $message);
439        static::assertTrue(file_exists($filename), $message ?: "Failed asserting that $filename exists.");
440    }
441
442    /**
443     * @param string $filename
444     * @param string $message
445     *
446     * @return void
447     */
448    public static function assertFileNotExists($filename, $message = '')
449    {
450        static::assertInternalType('string', $filename, $message);
451        static::assertFalse(file_exists($filename), $message ?: "Failed asserting that $filename does not exist.");
452    }
453
454    /**
455     * @param string $filename
456     * @param string $message
457     *
458     * @return void
459     */
460    public static function assertFileDoesNotExist($filename, $message = '')
461    {
462        static::assertFileNotExists($filename, $message);
463    }
464
465    /**
466     * @param string $filename
467     * @param string $message
468     *
469     * @return void
470     */
471    public static function assertFileIsReadable($filename, $message = '')
472    {
473        static::assertFileExists($filename, $message);
474        static::assertIsReadable($filename, $message);
475    }
476
477    /**
478     * @param string $filename
479     * @param string $message
480     *
481     * @return void
482     */
483    public static function assertFileNotIsReadable($filename, $message = '')
484    {
485        static::assertFileExists($filename, $message);
486        static::assertNotIsReadable($filename, $message);
487    }
488
489    /**
490     * @param string $filename
491     * @param string $message
492     *
493     * @return void
494     */
495    public static function assertFileIsNotReadable($filename, $message = '')
496    {
497        static::assertFileNotIsReadable($filename, $message);
498    }
499
500    /**
501     * @param string $filename
502     * @param string $message
503     *
504     * @return void
505     */
506    public static function assertFileIsWritable($filename, $message = '')
507    {
508        static::assertFileExists($filename, $message);
509        static::assertIsWritable($filename, $message);
510    }
511
512    /**
513     * @param string $filename
514     * @param string $message
515     *
516     * @return void
517     */
518    public static function assertFileNotIsWritable($filename, $message = '')
519    {
520        static::assertFileExists($filename, $message);
521        static::assertNotIsWritable($filename, $message);
522    }
523
524    /**
525     * @param string $filename
526     * @param string $message
527     *
528     * @return void
529     */
530    public static function assertFileIsNotWritable($filename, $message = '')
531    {
532        static::assertFileNotIsWritable($filename, $message);
533    }
534
535    /**
536     * @param string $pattern
537     * @param string $string
538     * @param string $message
539     *
540     * @return void
541     */
542    public static function assertMatchesRegularExpression($pattern, $string, $message = '')
543    {
544        static::assertRegExp($pattern, $string, $message);
545    }
546
547    /**
548     * @param string $pattern
549     * @param string $string
550     * @param string $message
551     *
552     * @return void
553     */
554    public static function assertDoesNotMatchRegularExpression($pattern, $string, $message = '')
555    {
556        static::assertNotRegExp($pattern, $string, $message);
557    }
558}