diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 72c250562..1afe2e232 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 59eb626e2..8d7974c25 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,7 @@ "phpunit/phpunit": "^9.5", "psalm/plugin-phpunit": "^0.18", "psalm/plugin-symfony": "^5.0", - "rector/rector": "^0.17", + "rector/rector": "^0.18", "sonata-project/admin-bundle": "^4.20", "sonata-project/block-bundle": "^4.11 || ^5.0", "sonata-project/doctrine-orm-admin-bundle": "^4.0", diff --git a/rector.php b/rector.php index 6454e91a6..dd4380e38 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/Action/LoginActionTest.php b/tests/Action/LoginActionTest.php index ca48ff503..8c736712f 100644 --- a/tests/Action/LoginActionTest.php +++ b/tests/Action/LoginActionTest.php @@ -134,7 +134,7 @@ public function testAlreadyAuthenticated(): void } /** - * @dataProvider unauthenticatedProvider + * @dataProvider provideUnauthenticatedCases */ public function testUnauthenticated(string $lastUsername, ?AuthenticationException $errorMessage = null): void { @@ -208,14 +208,11 @@ public function testUnauthenticated(string $lastUsername, ?AuthenticationExcepti * * @phpstan-return iterable */ - public function unauthenticatedProvider(): iterable + public function provideUnauthenticatedCases(): iterable { $error = new AuthenticationException('An error'); - - return [ - ['', null], - ['FooUser', $error], - ]; + yield ['', null]; + yield ['FooUser', $error]; } private function getAction(): LoginAction diff --git a/tests/Functional/Admin/UserAdminTest.php b/tests/Functional/Admin/UserAdminTest.php index 05fea33af..c5d67f627 100644 --- a/tests/Functional/Admin/UserAdminTest.php +++ b/tests/Functional/Admin/UserAdminTest.php @@ -54,7 +54,7 @@ public static function provideCrudUrlsCases(): iterable } /** - * @dataProvider provideFormUrlsCases + * @dataProvider provideFormsUrlsCases * * @param array $parameters * @param array $fieldValues @@ -77,7 +77,7 @@ public function testFormsUrls(string $url, array $parameters, string $button, ar * * @phpstan-return iterable, 2: string, 3?: array}> */ - public static function provideFormUrlsCases(): iterable + public static function provideFormsUrlsCases(): iterable { yield 'Create User' => ['/admin/tests/app/user/create', [ 'uniqid' => 'user', diff --git a/tests/Mailer/MailerTest.php b/tests/Mailer/MailerTest.php index 4669e6bab..a8caa5f40 100644 --- a/tests/Mailer/MailerTest.php +++ b/tests/Mailer/MailerTest.php @@ -68,7 +68,7 @@ public function testSendConfirmationEmailMessage(): void } /** - * @dataProvider emailTemplateData + * @dataProvider provideSendResettingEmailMessageCases */ public function testSendResettingEmailMessage(string $template, string $subject, string $body): void { @@ -111,15 +111,13 @@ public function testSendResettingEmailMessage(string $template, string $subject, * * @phpstan-return iterable */ - public function emailTemplateData(): iterable + public function provideSendResettingEmailMessageCases(): iterable { - return [ - 'CR' => ["Subject\rFirst line\rSecond line", 'Subject', "First line\rSecond line"], - 'LF' => ["Subject\nFirst line\nSecond line", 'Subject', "First line\nSecond line"], - 'CRLF' => ["Subject\r\nFirst line\r\nSecond line", 'Subject', "First line\r\nSecond line"], - 'LFLF' => ["Subject\n\nFirst line\n\nSecond line", 'Subject', "\nFirst line\n\nSecond line"], - 'CRCR' => ["Subject\r\rFirst line\r\rSecond line", 'Subject', "\rFirst line\r\rSecond line"], - ]; + yield 'CR' => ["Subject\rFirst line\rSecond line", 'Subject', "First line\rSecond line"]; + yield 'LF' => ["Subject\nFirst line\nSecond line", 'Subject', "First line\nSecond line"]; + yield 'CRLF' => ["Subject\r\nFirst line\r\nSecond line", 'Subject', "First line\r\nSecond line"]; + yield 'LFLF' => ["Subject\n\nFirst line\n\nSecond line", 'Subject', "\nFirst line\n\nSecond line"]; + yield 'CRCR' => ["Subject\r\rFirst line\r\rSecond line", 'Subject', "\rFirst line\r\rSecond line"]; } private function getMailer(): Mailer