diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 72c25056..1afe2e23 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -56,6 +56,8 @@ ]], 'php_unit_strict' => true, 'php_unit_test_case_static_method_calls' => true, + 'php_unit_data_provider_name' => true, + 'php_unit_data_provider_return_type' => true, 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'phpstan-var']], 'single_line_throw' => false, 'static_lambda' => true, diff --git a/composer.json b/composer.json index cc5ff4df..f00b2c55 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "phpunit/phpunit": "^9.5", "psalm/plugin-phpunit": "^0.18", "psalm/plugin-symfony": "^5.0", - "rector/rector": "^0.17", + "rector/rector": "^0.18", "symfony/config": "^5.4 || ^6.2", "symfony/dependency-injection": "^5.4 || ^6.2", "symfony/http-foundation": "^5.4 || ^6.2", diff --git a/rector.php b/rector.php index 6454e91a..dd4380e3 100644 --- a/rector.php +++ b/rector.php @@ -20,6 +20,10 @@ use Rector\Config\RectorConfig; use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector; use Rector\Php71\Rector\FuncCall\CountOnNullRector; +use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector; +use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; +use Rector\PHPUnit\Set\PHPUnitLevelSetList; +use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -30,6 +34,8 @@ $rectorConfig->sets([ LevelSetList::UP_TO_PHP_80, + PHPUnitLevelSetList::UP_TO_PHPUNIT_90, + PHPUnitSetList::PHPUNIT_CODE_QUALITY, ]); $rectorConfig->importNames(); @@ -37,5 +43,7 @@ $rectorConfig->skip([ CountOnNullRector::class, ExceptionHandlerTypehintRector::class, + AddSeeTestAnnotationRector::class, + PreferPHPUnitThisCallRector::class, ]); }; diff --git a/tests/ExporterTest.php b/tests/ExporterTest.php index cab7a1d6..e75bdb1c 100644 --- a/tests/ExporterTest.php +++ b/tests/ExporterTest.php @@ -58,7 +58,7 @@ public function testGetAvailableFormats(): void } /** - * @dataProvider getGetResponseTests + * @dataProvider provideGetResponseCases */ public function testGetResponse(string $format, string $filename, string $contentType, string $expectedOutput): void { @@ -90,16 +90,14 @@ public function testGetResponse(string $format, string $filename, string $conten } /** - * @return array + * @return iterable */ - public function getGetResponseTests(): array + public function provideGetResponseCases(): iterable { - return [ - ['json', 'foo.json', 'application/json', '#foo#'], - ['xml', 'foo.xml', 'text/xml', '#foo#'], - ['xls', 'foo.xls', 'application/vnd.ms-excel', '#foo#'], - ['csv', 'foo.csv', 'text/csv', '#foo#'], - ['made-up', 'foo.made-up', 'application/made-up', '##'], - ]; + yield ['json', 'foo.json', 'application/json', '#foo#']; + yield ['xml', 'foo.xml', 'text/xml', '#foo#']; + yield ['xls', 'foo.xls', 'application/vnd.ms-excel', '#foo#']; + yield ['csv', 'foo.csv', 'text/csv', '#foo#']; + yield ['made-up', 'foo.made-up', 'application/made-up', '##']; } } diff --git a/tests/Source/AbstractPropertySourceIteratorTest.php b/tests/Source/AbstractPropertySourceIteratorTest.php index 3cdc3334..620cc8dc 100644 --- a/tests/Source/AbstractPropertySourceIteratorTest.php +++ b/tests/Source/AbstractPropertySourceIteratorTest.php @@ -20,7 +20,7 @@ final class AbstractPropertySourceIteratorTest extends TestCase { /** - * @dataProvider getValueProvider + * @dataProvider provideGetValueCases */ public function testGetValue(mixed $value, mixed $expected, string $dateFormat = 'r'): void { @@ -41,9 +41,9 @@ public function getValue(mixed $value): bool|int|float|string|null } /** - * @return array + * @return iterable */ - public function getValueProvider(): array + public function provideGetValueCases(): iterable { $datetime = new \DateTime(); $dateTimeImmutable = new \DateTimeImmutable(); diff --git a/tests/Writer/JsonWriterTest.php b/tests/Writer/JsonWriterTest.php index 960168bd..dbde4d6f 100644 --- a/tests/Writer/JsonWriterTest.php +++ b/tests/Writer/JsonWriterTest.php @@ -57,6 +57,6 @@ public function testWrite(): void ['john 3', 'doe', '1'], ]; - static::assertSame($expected, json_decode($content, false)); + static::assertSame($expected, json_decode($content, false, 512, \JSON_THROW_ON_ERROR)); } }