1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-10-25 12:06:12 +02:00

php 7.1 - 8.0 compatible version

issue #78
This commit is contained in:
Ne-Lexa
2021-05-16 12:18:23 +03:00
parent 7283fc3402
commit 584784c119
73 changed files with 1446 additions and 958 deletions

View 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;
}

View 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);
}
}

View 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);
}
}