Skip to content

Commit

Permalink
Upgrade PHPUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 4, 2024
1 parent 2e07856 commit a422df5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 26 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@
"ext-sysvsem": "*",
"eloquent/liberator": "^2.0 || ^3.0",
"ergebnis/composer-normalize": "^2.13",
"ergebnis/phpunit-slow-test-detector": "^2.9",
"friendsofphp/php-cs-fixer": "^3.0",
"mikey179/vfsstream": "^1.6.11",
"php-mock/php-mock-phpunit": "^2.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^9.5.25 || ^10.0 || ^11.0",
"predis/predis": "^1.1.8",
"spatie/async": "^1.5"
},
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ parameters:
identifier: empty.notAllowed
message: '~^Construct empty\(\) is not allowed\. Use more strict comparison\.$~'
count: 6
-
path: '*'
identifier: method.deprecated
message: '~^Call to deprecated method getMockForAbstractClass\(\) of class PHPUnit\\Framework\\TestCase:\nhttps://github.com/sebastianbergmann/phpunit/issues/5241$~'
count: 8
31 changes: 17 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.4/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests</directory>
<testsuite name="tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<extensions>
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension" />
</extensions>
<source>
<include>
<directory>src</directory>
<directory>tests</directory>
</include>
</source>
<coverage>
<report>
<php outputFile="coverage/phpunit.cov" />
</report>
</coverage>
</phpunit>
29 changes: 19 additions & 10 deletions tests/mutex/PgAdvisoryLockMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ protected function setUp(): void
$this->mutex = new PgAdvisoryLockMutex($this->pdo, 'test' . uniqid());
}

private function isPhpunit9x(): bool
{
return (new \ReflectionClass(self::class))->hasMethod('getStatus');
}

public function testAcquireLock(): void
{
$statement = $this->createMock(\PDOStatement::class);
Expand All @@ -39,11 +44,13 @@ public function testAcquireLock(): void
self::logicalAnd(
self::isType('array'),
self::countOf(2),
self::callback(static function (...$arguments): bool {
$integers = $arguments[0];
self::callback(function (...$arguments): bool {
if ($this->isPhpunit9x()) { // https://github.com/sebastianbergmann/phpunit/issues/5891
$arguments = $arguments[0];
}

foreach ($integers as $each) {
self::assertIsInt($each);
foreach ($arguments as $v) {
self::assertIsInt($v);
}

return true;
Expand All @@ -69,13 +76,15 @@ public function testReleaseLock(): void
self::logicalAnd(
self::isType('array'),
self::countOf(2),
self::callback(static function (...$arguments): bool {
$integers = $arguments[0];
self::callback(function (...$arguments): bool {
if ($this->isPhpunit9x()) { // https://github.com/sebastianbergmann/phpunit/issues/5891
$arguments = $arguments[0];
}

foreach ($integers as $each) {
self::assertLessThan(1 << 32, $each);
self::assertGreaterThan(-(1 << 32), $each);
self::assertIsInt($each);
foreach ($arguments as $v) {
self::assertLessThan(1 << 32, $v);
self::assertGreaterThan(-(1 << 32), $v);
self::assertIsInt($v);
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion tests/mutex/PredisMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected function setUp(): void
parent::setUp();

$this->client = $this->getMockBuilder(ClientInterface::class) // @phpstan-ignore method.deprecated
->setMethods(array_merge(get_class_methods(ClientInterface::class), ['set', 'eval']))
->onlyMethods(get_class_methods(ClientInterface::class))
->addMethods(['set', 'eval'])
->getMock();

$this->mutex = new PredisMutex([$this->client], 'test', 2.5);
Expand Down

0 comments on commit a422df5

Please sign in to comment.