Skip to content

Commit 434e41b

Browse files
Update dev dependency phpunit to 10 and 11 (#42)
* Add support for phpunit 11 * Add support for phpunit 10
1 parent 6f2bfb1 commit 434e41b

33 files changed

+79
-404
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Setup PHP
5454
uses: shivammathur/setup-php@v2
5555
with:
56-
php-version: 8.2
56+
php-version: 8.1
5757
coverage: pcov
5858

5959
- name: Install dependencies

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"roave/security-advisories": "dev-latest",
3737
"squizlabs/php_codesniffer": "^3.7",
3838
"phpmd/phpmd": "^2.14",
39-
"phpunit/phpunit": "^9.6",
39+
"phpunit/phpunit": "^10.0 || ^11.2",
4040
"phpstan/phpstan": "^1.10",
4141
"phpstan/phpstan-phpunit": "^1.3",
4242
"phpstan/phpstan-strict-rules": "^1.5",

phpunit.xml.dist

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
forceCoversAnnotation="true"
65
failOnRisky="true"
76
failOnWarning="true"
87
beStrictAboutChangesToGlobalState="true"
98
beStrictAboutOutputDuringTests="true"
10-
beStrictAboutResourceUsageDuringSmallTests="true"
11-
beStrictAboutTodoAnnotatedTests="true"
129
executionOrder="defects"
10+
cacheDirectory=".phpunit.cache"
11+
requireCoverageMetadata="true"
1312
>
1413
<testsuites>
1514
<testsuite name="functional">
@@ -19,7 +18,7 @@
1918
<directory>tests/Unit</directory>
2019
</testsuite>
2120
</testsuites>
22-
<coverage processUncoveredFiles="true">
21+
<coverage>
2322
<include>
2423
<directory suffix=".php">src</directory>
2524
</include>

tests/Functional/Command/BaselineCommand/BaselineCommandTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
use org\bovigo\vfs\vfsStream;
99
use org\bovigo\vfs\vfsStreamDirectory;
1010
use org\bovigo\vfs\vfsStreamFile;
11+
use PHPUnit\Framework\Attributes\CoversNothing;
1112
use PHPUnit\Framework\TestCase;
1213
use Symfony\Component\Console\Command\Command;
1314
use Symfony\Component\Console\Input\ArgvInput;
1415
use Symfony\Component\Console\Output\BufferedOutput;
1516

17+
#[CoversNothing]
1618
class BaselineCommandTest extends TestCase
1719
{
1820
/** @var vfsStreamDirectory */
@@ -25,7 +27,6 @@ protected function setUp(): void
2527
}
2628

2729
/**
28-
* @coversNothing
2930
* @throws Exception
3031
*/
3132
public function testBaselineCommand(): void

tests/Functional/Command/InspectCommand/InspectCommandMultiFileTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
use org\bovigo\vfs\vfsStream;
99
use org\bovigo\vfs\vfsStreamDirectory;
1010
use org\bovigo\vfs\vfsStreamFile;
11+
use PHPUnit\Framework\Attributes\CoversNothing;
1112
use PHPUnit\Framework\TestCase;
1213
use Symfony\Component\Console\Command\Command;
1314
use Symfony\Component\Console\Exception\ExceptionInterface;
1415
use Symfony\Component\Console\Input\ArgvInput;
1516
use Symfony\Component\Console\Output\ConsoleOutput;
1617

18+
#[CoversNothing]
1719
class InspectCommandMultiFileTest extends TestCase
1820
{
1921
private vfsStreamDirectory $fileSystem;
@@ -25,7 +27,6 @@ protected function setUp(): void
2527
}
2628

2729
/**
28-
* @coversNothing
2930
* @throws Exception|ExceptionInterface
3031
*/
3132
public function testInspectCommand(): void

tests/Functional/Command/InspectCommand/InspectCommandTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
use org\bovigo\vfs\vfsStream;
99
use org\bovigo\vfs\vfsStreamDirectory;
1010
use org\bovigo\vfs\vfsStreamFile;
11+
use PHPUnit\Framework\Attributes\CoversNothing;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1113
use PHPUnit\Framework\TestCase;
1214
use Symfony\Component\Console\Command\Command;
1315
use Symfony\Component\Console\Exception\ExceptionInterface;
1416
use Symfony\Component\Console\Input\ArgvInput;
1517
use Symfony\Component\Console\Output\ConsoleOutput;
1618

19+
#[CoversNothing]
1720
class InspectCommandTest extends TestCase
1821
{
1922
private vfsStreamDirectory $fileSystem;
@@ -27,10 +30,9 @@ protected function setUp(): void
2730
/**
2831
* @param string[] $flags
2932
*
30-
* @coversNothing
31-
* @dataProvider dataProvider
3233
* @throws Exception|ExceptionInterface
3334
*/
35+
#[DataProvider('dataProvider')]
3436
public function testInspectCommand(array $flags, int $exitStatus): void
3537
{
3638
// prepare data files
@@ -62,7 +64,7 @@ public function testInspectCommand(array $flags, int $exitStatus): void
6264
/**
6365
* @return array<string, array{0: string[], 1:int}>
6466
*/
65-
public function dataProvider(): array
67+
public static function dataProvider(): array
6668
{
6769
return [
6870
'standard exit code' => [[], Command::SUCCESS],

tests/Unit/Lib/Config/ConfigFactoryTest.php

+2-28
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
use DigitalRevolution\CodeCoverageInspection\Lib\Config\ConfigViolation;
88
use DigitalRevolution\CodeCoverageInspection\Lib\Config\InspectConfig;
99
use org\bovigo\vfs\vfsStream;
10+
use PHPUnit\Framework\Attributes\CoversClass;
1011
use PHPUnit\Framework\TestCase;
1112
use Symfony\Component\Console\Input\InputInterface;
1213

13-
/**
14-
* @coversDefaultClass \DigitalRevolution\CodeCoverageInspection\Lib\Config\ConfigFactory
15-
* @covers ::getReport
16-
*/
14+
#[CoversClass(ConfigFactory::class)]
1715
class ConfigFactoryTest extends TestCase
1816
{
1917
private ConfigFactory $factory;
@@ -25,9 +23,6 @@ protected function setUp(): void
2523
$this->factory = new ConfigFactory();
2624
}
2725

28-
/**
29-
* @covers ::createInspectConfig
30-
*/
3126
public function testCreateInspectConfigMinimal(): void
3227
{
3328
$configPath = $this->filepath . 'config.xml';
@@ -50,9 +45,6 @@ public function testCreateInspectConfigMinimal(): void
5045
static::assertTrue($config->isExitCodeOnFailure());
5146
}
5247

53-
/**
54-
* @covers ::createInspectConfig
55-
*/
5648
public function testCreateInspectConfigMultiReport(): void
5749
{
5850
$configPath = $this->filepath . 'config.xml';
@@ -75,9 +67,6 @@ public function testCreateInspectConfigMultiReport(): void
7567
static::assertFalse($config->isExitCodeOnFailure());
7668
}
7769

78-
/**
79-
* @covers ::createInspectConfig
80-
*/
8170
public function testCreateInspectConfigInvalidCoverage(): void
8271
{
8372
$configPath = $this->filepath . 'config.xml';
@@ -93,9 +82,6 @@ public function testCreateInspectConfigInvalidCoverage(): void
9382
static::assertEquals(new ConfigViolation('Coverage argument should be an array'), $config);
9483
}
9584

96-
/**
97-
* @covers ::createInspectConfig
98-
*/
9985
public function testCreateInspectConfigInvalidBaseDir(): void
10086
{
10187
$configPath = $this->filepath . 'config.xml';
@@ -111,9 +97,6 @@ public function testCreateInspectConfigInvalidBaseDir(): void
11197
static::assertEquals(new ConfigViolation('--base-dir expecting a value string as argument'), $config);
11298
}
11399

114-
/**
115-
* @covers ::createInspectConfig
116-
*/
117100
public function testCreateInspectConfigInvalidGitlabReport(): void
118101
{
119102
$configPath = $this->filepath . 'config.xml';
@@ -129,9 +112,6 @@ public function testCreateInspectConfigInvalidGitlabReport(): void
129112
static::assertEquals(new ConfigViolation('--reportGitlab expecting the value to absent or string argument'), $config);
130113
}
131114

132-
/**
133-
* @covers ::createInspectConfig
134-
*/
135115
public function testCreateInspectConfigInvalidCheckstyleReport(): void
136116
{
137117
$configPath = $this->filepath . 'config.xml';
@@ -147,9 +127,6 @@ public function testCreateInspectConfigInvalidCheckstyleReport(): void
147127
static::assertEquals(new ConfigViolation('--reportCheckstyle expecting the value to absent or string argument'), $config);
148128
}
149129

150-
/**
151-
* @covers ::createInspectConfig
152-
*/
153130
public function testCreateInspectConfigInvalidTextReport(): void
154131
{
155132
$configPath = $this->filepath . 'config.xml';
@@ -165,9 +142,6 @@ public function testCreateInspectConfigInvalidTextReport(): void
165142
static::assertEquals(new ConfigViolation('--reportText expecting the value to absent or string argument'), $config);
166143
}
167144

168-
/**
169-
* @covers ::createInspectConfig
170-
*/
171145
public function testCreateInspectConfigDuplicateOutputReport(): void
172146
{
173147
$configPath = $this->filepath . 'config.xml';

tests/Unit/Lib/Config/ConfigViolationTest.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55

66
use DigitalRevolution\AccessorPairConstraint\AccessorPairAsserter;
77
use DigitalRevolution\CodeCoverageInspection\Lib\Config\ConfigViolation;
8+
use PHPUnit\Framework\Attributes\CoversClass;
89
use PHPUnit\Framework\TestCase;
910

10-
/**
11-
* @coversDefaultClass \DigitalRevolution\CodeCoverageInspection\Lib\Config\ConfigViolation
12-
* @covers ::__construct
13-
*/
11+
#[CoversClass(ConfigViolation::class)]
1412
class ConfigViolationTest extends TestCase
1513
{
1614
use AccessorPairAsserter;
1715

18-
/**
19-
* @covers ::<public>
20-
*/
2116
public function testAccessorPairs(): void
2217
{
2318
static::assertAccessorPairs(ConfigViolation::class);

tests/Unit/Lib/Config/InspectConfigTest.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55

66
use DigitalRevolution\AccessorPairConstraint\AccessorPairAsserter;
77
use DigitalRevolution\CodeCoverageInspection\Lib\Config\InspectConfig;
8+
use PHPUnit\Framework\Attributes\CoversClass;
89
use PHPUnit\Framework\TestCase;
910

10-
/**
11-
* @coversDefaultClass \DigitalRevolution\CodeCoverageInspection\Lib\Config\InspectConfig
12-
* @covers ::__construct
13-
*/
11+
#[CoversClass(InspectConfig::class)]
1412
class InspectConfigTest extends TestCase
1513
{
1614
use AccessorPairAsserter;
1715

18-
/**
19-
* @covers ::<public>
20-
*/
2116
public function testAccessorPairs(): void
2217
{
2318
static::assertAccessorPairs(InspectConfig::class);

tests/Unit/Lib/IO/DOMDocumentFactoryTest.php

+2-22
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
namespace DigitalRevolution\CodeCoverageInspection\Tests\Unit\Lib\IO;
55

66
use DigitalRevolution\CodeCoverageInspection\Lib\IO\DOMDocumentFactory;
7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use RuntimeException;
910
use SplFileInfo;
1011

11-
/**
12-
* @coversDefaultClass \DigitalRevolution\CodeCoverageInspection\Lib\IO\DOMDocumentFactory
13-
*/
12+
#[CoversClass(DOMDocumentFactory::class)]
1413
class DOMDocumentFactoryTest extends TestCase
1514
{
1615
/** @var resource */
@@ -27,9 +26,6 @@ protected function setUp(): void
2726
$this->schemaPath = dirname(__DIR__, 4) . '/resources/phpfci.xsd';
2827
}
2928

30-
/**
31-
* @covers ::getDOMDocument
32-
*/
3329
public function testGetDOMDocumentMissingFileShouldFail(): void
3430
{
3531
$file = new SplFileInfo('/a/b/c');
@@ -38,10 +34,6 @@ public function testGetDOMDocumentMissingFileShouldFail(): void
3834
DOMDocumentFactory::getDOMDocument($file);
3935
}
4036

41-
/**
42-
* @covers ::getDOMDocument
43-
* @covers ::getValidatedDOMDocument
44-
*/
4537
public function testGetDOMDocumentShouldPass(): void
4638
{
4739
$xml = '<?xml version="1.0" encoding="UTF-8"?>
@@ -56,10 +48,6 @@ public function testGetDOMDocumentShouldPass(): void
5648
static::assertSame('1.0', $dom->xmlVersion);
5749
}
5850

59-
/**
60-
* @covers ::getDOMDocument
61-
* @covers ::getValidatedDOMDocument
62-
*/
6351
public function testGetDOMDocumentWithoutCustomCoverageShouldPass(): void
6452
{
6553
$xml = '<?xml version="1.0" encoding="UTF-8"?>
@@ -71,10 +59,6 @@ public function testGetDOMDocumentWithoutCustomCoverageShouldPass(): void
7159
static::assertSame('1.0', $dom->xmlVersion);
7260
}
7361

74-
/**
75-
* @covers ::getDOMDocument
76-
* @covers ::getValidatedDOMDocument
77-
*/
7862
public function testGetDOMDocumentWithInvalidCoverageShouldFail(): void
7963
{
8064
$xml = '<?xml version="1.0" encoding="UTF-8"?>
@@ -88,10 +72,6 @@ public function testGetDOMDocumentWithInvalidCoverageShouldFail(): void
8872
DOMDocumentFactory::getValidatedDOMDocument($this->fileInfo, $this->schemaPath);
8973
}
9074

91-
/**
92-
* @covers ::getDOMDocument
93-
* @covers ::getValidatedDOMDocument
94-
*/
9575
public function testGetDOMDocumentWithInvalidCoverage(): void
9676
{
9777
$xml = '<?xml version="1.0" encoding="UTF-8"?>

tests/Unit/Lib/IO/IgnoreUncoveredMethodFileFactoryTest.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
use DigitalRevolution\CodeCoverageInspection\Lib\IO\IgnoreUncoveredMethodFileFactory;
77
use DOMDocument;
88
use DOMException;
9+
use PHPUnit\Framework\Attributes\CoversClass;
910
use PHPUnit\Framework\TestCase;
1011
use RuntimeException;
1112

12-
/**
13-
* @coversDefaultClass \DigitalRevolution\CodeCoverageInspection\Lib\IO\IgnoreUncoveredMethodFileFactory
14-
*/
13+
#[CoversClass(IgnoreUncoveredMethodFileFactory::class)]
1514
class IgnoreUncoveredMethodFileFactoryTest extends TestCase
1615
{
1716
/**
18-
* @covers ::createFromNode
1917
* @throws DOMException
2018
*/
2119
public function testCreateFromNodeInvalidNodeThrowsException(): void
@@ -29,7 +27,6 @@ public function testCreateFromNodeInvalidNodeThrowsException(): void
2927
}
3028

3129
/**
32-
* @covers ::createFromNode
3330
* @throws DOMException
3431
*/
3532
public function testCreateFromNode(): void

0 commit comments

Comments
 (0)