mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-10-25 12:06:12 +02:00
18
tests/Polyfill/LegacyTestCase.php
Normal file
18
tests/Polyfill/LegacyTestCase.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpZip\Tests\Polyfill;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @small
|
||||
*/
|
||||
class LegacyTestCase extends TestCase
|
||||
{
|
||||
use PhpUnit8CompatTrait;
|
||||
use PhpUnit9CompatTrait;
|
||||
}
|
||||
22
tests/Polyfill/PhpUnit8CompatTrait.php
Normal file
22
tests/Polyfill/PhpUnit8CompatTrait.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace PhpZip\Tests\Polyfill;
|
||||
|
||||
use PHPUnit\Runner\Version;
|
||||
|
||||
trait PhpUnit8CompatTrait
|
||||
{
|
||||
/**
|
||||
* @param string $regularExpression
|
||||
*/
|
||||
public function expectExceptionMessageMatches(string $regularExpression): void
|
||||
{
|
||||
if (version_compare(Version::id(), '8.0.0', '<')) {
|
||||
$this->expectExceptionMessageRegExp($regularExpression);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::expectExceptionMessageMatches($regularExpression);
|
||||
}
|
||||
}
|
||||
53
tests/Polyfill/PhpUnit9CompatTrait.php
Normal file
53
tests/Polyfill/PhpUnit9CompatTrait.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpZip\Tests\Polyfill;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Runner\Version;
|
||||
use SebastianBergmann\RecursionContext\InvalidArgumentException;
|
||||
|
||||
trait PhpUnit9CompatTrait
|
||||
{
|
||||
/**
|
||||
* Asserts that a file does not exist.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ExpectationFailedException
|
||||
*
|
||||
* @noinspection PhpDeprecationInspection
|
||||
*/
|
||||
public static function assertFileDoesNotExist(string $filename, string $message = ''): void
|
||||
{
|
||||
if (version_compare(Version::id(), '9.1.0', '<')) {
|
||||
static::assertFileNotExists($filename, $message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::assertFileDoesNotExist($filename, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a directory does not exist.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @noinspection PhpDeprecationInspection
|
||||
*/
|
||||
public static function assertDirectoryDoesNotExist(string $directory, string $message = ''): void
|
||||
{
|
||||
if (version_compare(Version::id(), '9.1.0', '<')) {
|
||||
static::assertDirectoryNotExists($directory, $message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::assertDirectoryDoesNotExist($directory, $message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user