mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Add stubs for renamed PHPUnit methods in PHPUnit 9
This commit is contained in:
parent
5c757340ae
commit
61df8cf321
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
{
|
||||
/**
|
||||
@ -51,4 +54,38 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
$property->setAccessible(true);
|
||||
return $property->setValue($object, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub for `assertFileNotExists` to allow compatibility with both PHPUnit 8 and 9.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public static function assertFileNotExists(string $filename, string $message = ''): void
|
||||
{
|
||||
if (method_exists(Assert::class, 'assertFileDoesNotExist')) {
|
||||
Assert::assertFileDoesNotExist($filename, $message);
|
||||
return;
|
||||
}
|
||||
|
||||
Assert::assertFileNotExists($filename, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub for `assertRegExp` to allow compatibility with both PHPUnit 8 and 9.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public static function assertRegExp(string $pattern, string $string, string $message = ''): void
|
||||
{
|
||||
if (method_exists(Assert::class, 'assertMatchesRegularExpression')) {
|
||||
Assert::assertMatchesRegularExpression($pattern, $string, $message);
|
||||
return;
|
||||
}
|
||||
|
||||
Assert::assertRegExp($pattern, $string, $message);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user