diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 808e54a5..778fccb4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,6 +41,6 @@ jobs: with: composer-options: "--prefer-dist --no-scripts" - - # https://github.com/sebastianbergmann/phpunit/tree/10.5 - name: Unit tests with PHPUnit 10 + - # https://github.com/sebastianbergmann/phpunit/tree/11.4 + name: Unit tests with PHPUnit 11 run: vendor/bin/phpunit --no-progress --testdox --do-not-cache-result diff --git a/phpunit.xml b/phpunit.xml index 1151c23a..f749b1c6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,6 @@ assertTrue(self::$cache->hasItem(__FILE__)); } - /** - * @covers \Overtrue\PHPLint\Cache::getItem - */ public function testGetItem(): void { // expected @@ -87,9 +88,6 @@ public function testGetItem(): void $this->assertSame($item->get(), $cacheItem->get()); } - /** - * @covers \Overtrue\PHPLint\Cache::saveItem - */ public function testSaveItem(): void { $filename = dirname(__DIR__) . '/EndToEnd/LintCommandTest.php'; @@ -103,59 +101,38 @@ public function testSaveItem(): void $this->assertEquals($fingerprint, self::$cache->getItem($filename)->get()); } - /** - * @covers \Overtrue\PHPLint\Cache::clear - */ public function testClearPool(): void { $cleared = self::$cache->clear(); $this->assertTrue($cleared); } - /** - * @covers \Overtrue\PHPLint\Cache::isHit - */ public function testCacheHit(): void { $this->assertTrue(self::$cache->isHit(__FILE__)); } - /** - * @covers \Overtrue\PHPLint\Cache::isHit - */ public function testCacheMiss(): void { $this->assertFalse(self::$cache->isHit(dirname(__DIR__) . '/EndToEnd/LintCommandTest.php')); } - /** - * @covers \Overtrue\PHPLint\Cache::isHit - */ public function testCacheMissWithFileUnknown(): void { $this->assertFalse(self::$cache->isHit(dirname(__DIR__) . '/Finder/FinderTest.php')); } - /** - * @covers \Overtrue\PHPLint\Cache::isHit - */ public function testCacheMissWithWrongFileFingerprint(): void { $this->assertFalse(self::$cache->isHit(dirname(__DIR__) . '/Configuration/ConfigResolverTest.php')); } - /** - * @covers \Overtrue\PHPLint\Cache::getCalls - */ public function testGetCalls(): void { // cache init calls count $this->assertCount(3, self::$cache->getCalls()); } - /** - * @covers \Overtrue\PHPLint\Cache::saveItem - */ public function testFilenameHasReservedCharacters(): void { $filename = dirname(__DIR__) . '/EndToEnd/Reserved@Keywords.php'; diff --git a/tests/Configuration/ConsoleConfigTest.php b/tests/Configuration/ConsoleConfigTest.php index f0422375..8a2e8591 100644 --- a/tests/Configuration/ConsoleConfigTest.php +++ b/tests/Configuration/ConsoleConfigTest.php @@ -16,22 +16,20 @@ use Overtrue\PHPLint\Command\LintCommand; use Overtrue\PHPLint\Configuration\ConsoleOptionsResolver; use Overtrue\PHPLint\Configuration\OptionDefinition; -use Overtrue\PHPLint\Configuration\OptionsFactory; use Overtrue\PHPLint\Configuration\Resolver; use Overtrue\PHPLint\Event\EventDispatcher; use Overtrue\PHPLint\Tests\TestCase; +use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\OptionsResolver\OptionsResolver; - use function dirname; use function realpath; +#[CoversMethod(ConsoleOptionsResolver::class, 'getOption')] +#[CoversMethod(ConsoleOptionsResolver::class, 'getOptions')] final class ConsoleConfigTest extends TestCase { - /** - * @covers \Overtrue\PHPLint\Configuration\ConsoleOptionsResolver::getOption - */ public function testConfigFileNotReadable(): void { $dispatcher = new EventDispatcher([]); @@ -44,10 +42,7 @@ public function testConfigFileNotReadable(): void $this->assertFalse(realpath($resolver->getOption(OptionDefinition::CONFIGURATION))); } - /** - * @covers \Overtrue\PHPLint\Configuration\ConsoleOptionsResolver::getOptions - * @dataProvider commandInputProvider - */ + #[DataProvider('commandInputProvider')] public function testCommandConfig(array $arguments, callable $fetchExpected): void { $dispatcher = new EventDispatcher([]); diff --git a/tests/Configuration/YamlConfigTest.php b/tests/Configuration/YamlConfigTest.php index d3d3fa9c..0b4c71af 100644 --- a/tests/Configuration/YamlConfigTest.php +++ b/tests/Configuration/YamlConfigTest.php @@ -16,18 +16,18 @@ use Overtrue\PHPLint\Command\LintCommand; use Overtrue\PHPLint\Configuration\FileOptionsResolver; use Overtrue\PHPLint\Configuration\OptionDefinition; -use Overtrue\PHPLint\Configuration\OptionsFactory; use Overtrue\PHPLint\Configuration\Resolver; use Overtrue\PHPLint\Event\EventDispatcher; use Overtrue\PHPLint\Tests\TestCase; +use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; +#[CoversMethod(FileOptionsResolver::class, 'getOption')] +#[CoversMethod(FileOptionsResolver::class, 'getOptions')] final class YamlConfigTest extends TestCase { - /** - * @covers \Overtrue\PHPLint\Configuration\FileOptionsResolver - */ public function testInvalidYamlFile(): void { $this->expectException(InvalidOptionsException::class); @@ -41,10 +41,7 @@ public function testInvalidYamlFile(): void new FileOptionsResolver($input); } - /** - * @covers \Overtrue\PHPLint\Configuration\FileOptionsResolver::getOptions - * @dataProvider commandInputProvider - */ + #[DataProvider('commandInputProvider')] public function testYamlConfig(array $arguments, callable $fetchExpected): void { $dispatcher = new EventDispatcher([]); diff --git a/tests/EndToEnd/LintCommandTest.php b/tests/EndToEnd/LintCommandTest.php index cc96cdf5..aba15414 100644 --- a/tests/EndToEnd/LintCommandTest.php +++ b/tests/EndToEnd/LintCommandTest.php @@ -16,8 +16,8 @@ use Overtrue\PHPLint\Command\LintCommand; use Overtrue\PHPLint\Console\Application; use Overtrue\PHPLint\Event\EventDispatcher; -use Overtrue\PHPLint\Extension\OutputFormat; use Overtrue\PHPLint\Tests\TestCase; +use PHPUnit\Framework\Attributes\CoversMethod; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; @@ -27,6 +27,7 @@ * @author Laurent Laville * @since Release 9.0.0 */ +#[CoversMethod(LintCommand::class, '')] final class LintCommandTest extends TestCase { private ?CommandTester $commandTester; @@ -54,9 +55,6 @@ protected function tearDown(): void $this->commandTester = null; } - /** - * @covers \Overtrue\PHPLint\Command\LintCommand - */ public function testLintDirectoryWithoutConfigurationAndCache(): void { $arguments = [ @@ -74,9 +72,6 @@ public function testLintDirectoryWithoutConfigurationAndCache(): void ); } - /** - * @covers \Overtrue\PHPLint\Command\LintCommand - */ public function testLintSyntaxErrorFileWithoutConfigurationAndCache(): void { $arguments = [ diff --git a/tests/Finder/FinderTest.php b/tests/Finder/FinderTest.php index a27e3aa2..fd70803a 100644 --- a/tests/Finder/FinderTest.php +++ b/tests/Finder/FinderTest.php @@ -21,6 +21,7 @@ use Overtrue\PHPLint\Event\EventDispatcher; use Overtrue\PHPLint\Finder; use Overtrue\PHPLint\Tests\TestCase; +use PHPUnit\Framework\Attributes\CoversMethod; use Symfony\Component\Console\Input\ArrayInput; use function array_keys; @@ -33,11 +34,9 @@ * @author Laurent Laville * @since Release 9.0.0 */ +#[CoversMethod(Finder::class, 'getFiles')] final class FinderTest extends TestCase { - /** - * @covers \Overtrue\PHPLint\Finder::getFiles - */ public function testAllPhpFilesFoundShouldExists(): void { $dispatcher = new EventDispatcher([]); @@ -62,9 +61,6 @@ public function testAllPhpFilesFoundShouldExists(): void } } - /** - * @covers \Overtrue\PHPLint\Finder::getFiles - */ public function testAllPathShouldExistsAndReadable(): void { $this->expectException(LogicException::class); @@ -86,9 +82,6 @@ public function testAllPathShouldExistsAndReadable(): void count($finder->getFiles()); } - /** - * @covers \Overtrue\PHPLint\Finder::getFiles - */ public function testSearchPhpFilesWithCondition(): void { $dispatcher = new EventDispatcher([]); diff --git a/tests/Output/OutputTest.php b/tests/Output/OutputTest.php index f97b2197..81399919 100644 --- a/tests/Output/OutputTest.php +++ b/tests/Output/OutputTest.php @@ -22,6 +22,7 @@ use Overtrue\PHPLint\Output\JunitOutput; use Overtrue\PHPLint\Output\LinterOutput; use Overtrue\PHPLint\Tests\TestCase; +use PHPUnit\Framework\Attributes\CoversMethod; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; @@ -37,6 +38,7 @@ * @author Laurent Laville * @since Release 9.5.3 */ +#[CoversMethod(JunitOutput::class, 'format')] final class OutputTest extends TestCase { private LinterOutput $linterOutput; @@ -73,9 +75,6 @@ protected function setUp(): void $this->linterOutput->setContext($configResolver, $startTime, 2, $defaults); } - /** - * @covers \Overtrue\PHPLint\Output\JunitOutput::format - */ public function testJunitOutput(): void { $stream = fopen('php://memory', 'w+'); diff --git a/vendor-bin/phpunit/composer.json b/vendor-bin/phpunit/composer.json index f4727287..e718ec17 100644 --- a/vendor-bin/phpunit/composer.json +++ b/vendor-bin/phpunit/composer.json @@ -1,5 +1,5 @@ { "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" } }