Skip to content

Commit 00a6f88

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [PhpUnitBridge] Create a predictable symlink pointing to the local install [PropertyInfo] Backport support for typed properties (PHP 7.4) [PhpUnitBridge] Polyfill new phpunit 9.1 assertions [PhpUnitBridge] Move assertMatchesRegularExpression in PolyfillAssertTrait [PhpUnit] Add polyfill for assertMatchesRegularExpression()
2 parents 964bd57 + 3a91b6e commit 00a6f88

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CHANGELOG
2525
-----
2626

2727
* added `ClassExistsMock`
28-
* bumped PHP version from 5.3.3 to 5.5.9
28+
* bumped PHP version from 5.3.3 to 5.5.9
2929
* split simple-phpunit bin into php file with code and a shell script
3030

3131
4.1.0

Legacy/PolyfillAssertTrait.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\Constraint\IsEqual;
1515
use PHPUnit\Framework\Constraint\LogicalNot;
16+
use PHPUnit\Framework\Constraint\RegularExpression;
1617
use PHPUnit\Framework\Constraint\StringContains;
1718
use PHPUnit\Framework\Constraint\TraversableContains;
1819

@@ -276,6 +277,17 @@ public static function assertNotIsReadable($filename, $message = '')
276277
static::assertFalse(is_readable($filename), $message ? $message : "Failed asserting that $filename is not readable.");
277278
}
278279

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+
279291
/**
280292
* @param string $filename
281293
* @param string $message
@@ -300,6 +312,17 @@ public static function assertNotIsWritable($filename, $message = '')
300312
static::assertFalse(is_writable($filename), $message ? $message : "Failed asserting that $filename is not writable.");
301313
}
302314

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+
303326
/**
304327
* @param string $directory
305328
* @param string $message
@@ -324,6 +347,17 @@ public static function assertDirectoryNotExists($directory, $message = '')
324347
static::assertFalse(is_dir($directory), $message ? $message : "Failed asserting that $directory does not exist.");
325348
}
326349

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+
327361
/**
328362
* @param string $directory
329363
* @param string $message
@@ -348,6 +382,17 @@ public static function assertDirectoryNotIsReadable($directory, $message = '')
348382
static::assertNotIsReadable($directory, $message);
349383
}
350384

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+
351396
/**
352397
* @param string $directory
353398
* @param string $message
@@ -372,6 +417,17 @@ public static function assertDirectoryNotIsWritable($directory, $message = '')
372417
static::assertNotIsWritable($directory, $message);
373418
}
374419

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+
375431
/**
376432
* @param string $filename
377433
* @param string $message
@@ -396,6 +452,17 @@ public static function assertFileNotExists($filename, $message = '')
396452
static::assertFalse(file_exists($filename), $message ? $message : "Failed asserting that $filename does not exist.");
397453
}
398454

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+
399466
/**
400467
* @param string $filename
401468
* @param string $message
@@ -420,6 +487,17 @@ public static function assertFileNotIsReadable($filename, $message = '')
420487
static::assertNotIsReadable($filename, $message);
421488
}
422489

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+
423501
/**
424502
* @param string $filename
425503
* @param string $message
@@ -443,4 +521,39 @@ public static function assertFileNotIsWritable($filename, $message = '')
443521
static::assertFileExists($filename, $message);
444522
static::assertNotIsWritable($filename, $message);
445523
}
524+
525+
/**
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
540+
*
541+
* @return void
542+
*/
543+
public static function assertMatchesRegularExpression($pattern, $string, $message = '')
544+
{
545+
static::assertRegExp($pattern, $string, $message);
546+
}
547+
548+
/**
549+
* @param string $pattern
550+
* @param string $string
551+
* @param string $message
552+
*
553+
* @return void
554+
*/
555+
public static function assertDoesNotMatchRegularExpression($pattern, $string, $message = '')
556+
{
557+
static::assertNotRegExp($message, $string, $message);
558+
}
446559
}

bin/simple-phpunit.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,16 @@ class SymfonyExcludeListPhpunit {}
284284
chdir($oldPwd);
285285
}
286286

287+
// Create a symlink with a predictable path pointing to the currently used version.
288+
// This is useful for static analytics tools such as PHPStan having to load PHPUnit's classes
289+
// and for other testing libraries such as Behat using PHPUnit's assertions.
290+
chdir($PHPUNIT_DIR);
291+
if (file_exists('phpunit')) {
292+
@unlink('phpunit');
293+
}
294+
@symlink($PHPUNIT_VERSION_DIR, 'phpunit');
295+
chdir($oldPwd);
296+
287297
if ($PHPUNIT_VERSION < 8.0) {
288298
$argv = array_filter($argv, function ($v) use (&$argc) {
289299
if ('--do-not-cache-result' !== $v) {

0 commit comments

Comments
 (0)