Skip to content

Commit a422df5

Browse files
committed
Upgrade PHPUnit
1 parent 2e07856 commit a422df5

File tree

5 files changed

+45
-26
lines changed

5 files changed

+45
-26
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@
4646
"ext-sysvsem": "*",
4747
"eloquent/liberator": "^2.0 || ^3.0",
4848
"ergebnis/composer-normalize": "^2.13",
49+
"ergebnis/phpunit-slow-test-detector": "^2.9",
4950
"friendsofphp/php-cs-fixer": "^3.0",
5051
"mikey179/vfsstream": "^1.6.11",
5152
"php-mock/php-mock-phpunit": "^2.1",
5253
"phpstan/extension-installer": "^1.1",
5354
"phpstan/phpstan": "^2.0",
5455
"phpstan/phpstan-deprecation-rules": "^2.0",
5556
"phpstan/phpstan-strict-rules": "^2.0",
56-
"phpunit/phpunit": "^9.4",
57+
"phpunit/phpunit": "^9.5.25 || ^10.0 || ^11.0",
5758
"predis/predis": "^1.1.8",
5859
"spatie/async": "^1.5"
5960
},

phpstan.neon.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ parameters:
3131
identifier: empty.notAllowed
3232
message: '~^Construct empty\(\) is not allowed\. Use more strict comparison\.$~'
3333
count: 6
34+
-
35+
path: '*'
36+
identifier: method.deprecated
37+
message: '~^Call to deprecated method getMockForAbstractClass\(\) of class PHPUnit\\Framework\\TestCase:\nhttps://github.com/sebastianbergmann/phpunit/issues/5241$~'
38+
count: 8

phpunit.xml.dist

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.4/phpunit.xsd"
4-
backupGlobals="false"
5-
backupStaticAttributes="false"
6-
bootstrap="vendor/autoload.php"
7-
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
11-
processIsolation="false"
12-
stopOnFailure="false">
1+
<phpunit bootstrap="vendor/autoload.php" colors="true">
132
<testsuites>
14-
<testsuite name="Unit">
15-
<directory suffix="Test.php">./tests</directory>
3+
<testsuite name="tests">
4+
<directory>tests</directory>
165
</testsuite>
176
</testsuites>
7+
<extensions>
8+
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension" />
9+
</extensions>
10+
<source>
11+
<include>
12+
<directory>src</directory>
13+
<directory>tests</directory>
14+
</include>
15+
</source>
16+
<coverage>
17+
<report>
18+
<php outputFile="coverage/phpunit.cov" />
19+
</report>
20+
</coverage>
1821
</phpunit>

tests/mutex/PgAdvisoryLockMutexTest.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ protected function setUp(): void
2424
$this->mutex = new PgAdvisoryLockMutex($this->pdo, 'test' . uniqid());
2525
}
2626

27+
private function isPhpunit9x(): bool
28+
{
29+
return (new \ReflectionClass(self::class))->hasMethod('getStatus');
30+
}
31+
2732
public function testAcquireLock(): void
2833
{
2934
$statement = $this->createMock(\PDOStatement::class);
@@ -39,11 +44,13 @@ public function testAcquireLock(): void
3944
self::logicalAnd(
4045
self::isType('array'),
4146
self::countOf(2),
42-
self::callback(static function (...$arguments): bool {
43-
$integers = $arguments[0];
47+
self::callback(function (...$arguments): bool {
48+
if ($this->isPhpunit9x()) { // https://github.com/sebastianbergmann/phpunit/issues/5891
49+
$arguments = $arguments[0];
50+
}
4451

45-
foreach ($integers as $each) {
46-
self::assertIsInt($each);
52+
foreach ($arguments as $v) {
53+
self::assertIsInt($v);
4754
}
4855

4956
return true;
@@ -69,13 +76,15 @@ public function testReleaseLock(): void
6976
self::logicalAnd(
7077
self::isType('array'),
7178
self::countOf(2),
72-
self::callback(static function (...$arguments): bool {
73-
$integers = $arguments[0];
79+
self::callback(function (...$arguments): bool {
80+
if ($this->isPhpunit9x()) { // https://github.com/sebastianbergmann/phpunit/issues/5891
81+
$arguments = $arguments[0];
82+
}
7483

75-
foreach ($integers as $each) {
76-
self::assertLessThan(1 << 32, $each);
77-
self::assertGreaterThan(-(1 << 32), $each);
78-
self::assertIsInt($each);
84+
foreach ($arguments as $v) {
85+
self::assertLessThan(1 << 32, $v);
86+
self::assertGreaterThan(-(1 << 32), $v);
87+
self::assertIsInt($v);
7988
}
8089

8190
return true;

tests/mutex/PredisMutexTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ protected function setUp(): void
3131
parent::setUp();
3232

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

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

0 commit comments

Comments
 (0)