Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64a2627

Browse filesBrowse files
minor #32931 [PhpUnitBridge] Polyfill assertion method on Filesystem (jderusse)
This PR was merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] Polyfill assertion method on Filesystem | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32844 | License | MIT | Doc PR | NA This PR provide polyfill for assert methods on filesystem (introduced in PhpUnit 5.0) - assert(File|Directory)?(Not)?Is(Readable|Writable) - assert(File|Directory)(Not)?exists Commits ------- 6d62574 Polyfill assertion method on Filesystem
2 parents aa93f0b + 6d62574 commit 64a2627
Copy full SHA for 64a2627

File tree

Expand file treeCollapse file tree

1 file changed

+193
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+193
-1
lines changed

‎src/Symfony/Bridge/PhpUnit/Legacy/PolyfillAssertTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/PolyfillAssertTrait.php
+193-1Lines changed: 193 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use PHPUnit\Framework\Constraint\TraversableContains;
1818

1919
/**
20-
* This trait is @internal
20+
* This trait is @internal.
2121
*/
2222
trait PolyfillAssertTrait
2323
{
@@ -251,4 +251,196 @@ public static function assertNan($actual, $message = '')
251251
static::assertInternalType('float', $actual, $message);
252252
static::assertTrue(is_nan($actual), $message ? $message : "Failed asserting that $actual is nan.");
253253
}
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 ? $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 ? $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 assertIsWritable($filename, $message = '')
286+
{
287+
static::assertInternalType('string', $filename, $message);
288+
static::assertTrue(is_writable($filename), $message ? $message : "Failed asserting that $filename is writable.");
289+
}
290+
291+
/**
292+
* @param string $filename
293+
* @param string $message
294+
*
295+
* @return void
296+
*/
297+
public static function assertNotIsWritable($filename, $message = '')
298+
{
299+
static::assertInternalType('string', $filename, $message);
300+
static::assertFalse(is_writable($filename), $message ? $message : "Failed asserting that $filename is not writable.");
301+
}
302+
303+
/**
304+
* @param string $directory
305+
* @param string $message
306+
*
307+
* @return void
308+
*/
309+
public static function assertDirectoryExists($directory, $message = '')
310+
{
311+
static::assertInternalType('string', $directory, $message);
312+
static::assertTrue(is_dir($directory), $message ? $message : "Failed asserting that $directory exists.");
313+
}
314+
315+
/**
316+
* @param string $directory
317+
* @param string $message
318+
*
319+
* @return void
320+
*/
321+
public static function assertDirectoryNotExists($directory, $message = '')
322+
{
323+
static::assertInternalType('string', $directory, $message);
324+
static::assertFalse(is_dir($directory), $message ? $message : "Failed asserting that $directory does not exist.");
325+
}
326+
327+
/**
328+
* @param string $directory
329+
* @param string $message
330+
*
331+
* @return void
332+
*/
333+
public static function assertDirectoryIsReadable($directory, $message = '')
334+
{
335+
static::assertDirectoryExists($directory, $message);
336+
static::assertIsReadable($directory, $message);
337+
}
338+
339+
/**
340+
* @param string $directory
341+
* @param string $message
342+
*
343+
* @return void
344+
*/
345+
public static function assertDirectoryNotIsReadable($directory, $message = '')
346+
{
347+
static::assertDirectoryExists($directory, $message);
348+
static::assertNotIsReadable($directory, $message);
349+
}
350+
351+
/**
352+
* @param string $directory
353+
* @param string $message
354+
*
355+
* @return void
356+
*/
357+
public static function assertDirectoryIsWritable($directory, $message = '')
358+
{
359+
static::assertDirectoryExists($directory, $message);
360+
static::assertIsWritable($directory, $message);
361+
}
362+
363+
/**
364+
* @param string $directory
365+
* @param string $message
366+
*
367+
* @return void
368+
*/
369+
public static function assertDirectoryNotIsWritable($directory, $message = '')
370+
{
371+
static::assertDirectoryExists($directory, $message);
372+
static::assertNotIsWritable($directory, $message);
373+
}
374+
375+
/**
376+
* @param string $filename
377+
* @param string $message
378+
*
379+
* @return void
380+
*/
381+
public static function assertFileExists($filename, $message = '')
382+
{
383+
static::assertInternalType('string', $filename, $message);
384+
static::assertTrue(file_exists($filename), $message ? $message : "Failed asserting that $filename exists.");
385+
}
386+
387+
/**
388+
* @param string $filename
389+
* @param string $message
390+
*
391+
* @return void
392+
*/
393+
public static function assertFileNotExists($filename, $message = '')
394+
{
395+
static::assertInternalType('string', $filename, $message);
396+
static::assertFalse(file_exists($filename), $message ? $message : "Failed asserting that $filename does not exist.");
397+
}
398+
399+
/**
400+
* @param string $filename
401+
* @param string $message
402+
*
403+
* @return void
404+
*/
405+
public static function assertFileIsReadable($filename, $message = '')
406+
{
407+
static::assertFileExists($filename, $message);
408+
static::assertIsReadable($filename, $message);
409+
}
410+
411+
/**
412+
* @param string $filename
413+
* @param string $message
414+
*
415+
* @return void
416+
*/
417+
public static function assertFileNotIsReadable($filename, $message = '')
418+
{
419+
static::assertFileExists($filename, $message);
420+
static::assertNotIsReadable($filename, $message);
421+
}
422+
423+
/**
424+
* @param string $filename
425+
* @param string $message
426+
*
427+
* @return void
428+
*/
429+
public static function assertFileIsWritable($filename, $message = '')
430+
{
431+
static::assertFileExists($filename, $message);
432+
static::assertIsWritable($filename, $message);
433+
}
434+
435+
/**
436+
* @param string $filename
437+
* @param string $message
438+
*
439+
* @return void
440+
*/
441+
public static function assertFileNotIsWritable($filename, $message = '')
442+
{
443+
static::assertFileExists($filename, $message);
444+
static::assertNotIsWritable($filename, $message);
445+
}
254446
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.