Skip to content

Commit 66a2dfc

Browse files
phpfournicolas-grekas
authored andcommitted
[PhpUnitBridge] Polyfill new phpunit 9.1 assertions
1 parent f00fa7b commit 66a2dfc

File tree

2 files changed

+102
-10
lines changed

2 files changed

+102
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CHANGELOG
1212
-----
1313

1414
* added `ClassExistsMock`
15-
* bumped PHP version from 5.3.3 to 5.5.9
15+
* bumped PHP version from 5.3.3 to 5.5.9
1616
* split simple-phpunit bin into php file with code and a shell script
1717

1818
4.1.0

Legacy/PolyfillAssertTrait.php

Lines changed: 101 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ public static function assertNotIsReadable($filename, $message = '')
277277
static::assertFalse(is_readable($filename), $message ? $message : "Failed asserting that $filename is not readable.");
278278
}
279279

280+
/**
281+
* @param string $filename
282+
* @param string $message
283+
*
284+
* @return void
285+
*/
286+
public static function assertIsNotReadable($filename, $message = '')
287+
{
288+
static::assertNotIsReadable($filename, $message);
289+
}
290+
280291
/**
281292
* @param string $filename
282293
* @param string $message
@@ -301,6 +312,17 @@ public static function assertNotIsWritable($filename, $message = '')
301312
static::assertFalse(is_writable($filename), $message ? $message : "Failed asserting that $filename is not writable.");
302313
}
303314

315+
/**
316+
* @param string $filename
317+
* @param string $message
318+
*
319+
* @return void
320+
*/
321+
public static function assertIsNotWritable($filename, $message = '')
322+
{
323+
static::assertNotIsWritable($filename, $message);
324+
}
325+
304326
/**
305327
* @param string $directory
306328
* @param string $message
@@ -325,6 +347,17 @@ public static function assertDirectoryNotExists($directory, $message = '')
325347
static::assertFalse(is_dir($directory), $message ? $message : "Failed asserting that $directory does not exist.");
326348
}
327349

350+
/**
351+
* @param string $directory
352+
* @param string $message
353+
*
354+
* @return void
355+
*/
356+
public static function assertDirectoryDoesNotExist($directory, $message = '')
357+
{
358+
static::assertDirectoryNotExists($directory, $message);
359+
}
360+
328361
/**
329362
* @param string $directory
330363
* @param string $message
@@ -349,6 +382,17 @@ public static function assertDirectoryNotIsReadable($directory, $message = '')
349382
static::assertNotIsReadable($directory, $message);
350383
}
351384

385+
/**
386+
* @param string $directory
387+
* @param string $message
388+
*
389+
* @return void
390+
*/
391+
public static function assertDirectoryIsNotReadable($directory, $message = '')
392+
{
393+
static::assertDirectoryNotIsReadable($directory, $message);
394+
}
395+
352396
/**
353397
* @param string $directory
354398
* @param string $message
@@ -373,6 +417,17 @@ public static function assertDirectoryNotIsWritable($directory, $message = '')
373417
static::assertNotIsWritable($directory, $message);
374418
}
375419

420+
/**
421+
* @param string $directory
422+
* @param string $message
423+
*
424+
* @return void
425+
*/
426+
public static function assertDirectoryIsNotWritable($directory, $message = '')
427+
{
428+
static::assertDirectoryNotIsWritable($directory, $message);
429+
}
430+
376431
/**
377432
* @param string $filename
378433
* @param string $message
@@ -397,6 +452,17 @@ public static function assertFileNotExists($filename, $message = '')
397452
static::assertFalse(file_exists($filename), $message ? $message : "Failed asserting that $filename does not exist.");
398453
}
399454

455+
/**
456+
* @param string $filename
457+
* @param string $message
458+
*
459+
* @return void
460+
*/
461+
public static function assertFileDoesNotExist($filename, $message = '')
462+
{
463+
static::assertFileNotExists($filename, $message);
464+
}
465+
400466
/**
401467
* @param string $filename
402468
* @param string $message
@@ -421,6 +487,17 @@ public static function assertFileNotIsReadable($filename, $message = '')
421487
static::assertNotIsReadable($filename, $message);
422488
}
423489

490+
/**
491+
* @param string $filename
492+
* @param string $message
493+
*
494+
* @return void
495+
*/
496+
public static function assertFileIsNotReadable($filename, $message = '')
497+
{
498+
static::assertFileNotIsReadable($filename, $message);
499+
}
500+
424501
/**
425502
* @param string $filename
426503
* @param string $message
@@ -446,22 +523,37 @@ public static function assertFileNotIsWritable($filename, $message = '')
446523
}
447524

448525
/**
449-
* Asserts that a string matches a given regular expression.
526+
* @param string $filename
527+
* @param string $message
528+
*
529+
* @return void
530+
*/
531+
public static function assertFileIsNotWritable($filename, $message = '')
532+
{
533+
static::assertFileNotIsWritable($filename, $message);
534+
}
535+
536+
/**
537+
* @param string $pattern
538+
* @param string $string
539+
* @param string $message
450540
*
541+
* @return void
542+
*/
543+
public static function assertMatchesRegularExpression($pattern, $string, $message = '')
544+
{
545+
static::assertRegExp($pattern, $string, $message);
546+
}
547+
548+
/**
451549
* @param string $pattern
452550
* @param string $string
453551
* @param string $message
454552
*
455553
* @return void
456554
*/
457-
public function assertMatchesRegularExpression($pattern, $string, $message = '')
555+
public static function assertDoesNotMatchRegularExpression($pattern, $string, $message = '')
458556
{
459-
static::assertThat(
460-
$string,
461-
new LogicalNot(
462-
new RegularExpression($pattern)
463-
),
464-
$message
465-
);
557+
static::assertNotRegExp($message, $string, $message);
466558
}
467559
}

0 commit comments

Comments
 (0)