Skip to content

Commit c4c2cf1

Browse files
committed
minor #21612 Replace PHPDoc dataProvider with attribute syntax (ttk)
This PR was submitted for the 8.0 branch but it was squashed and merged into the 7.3 branch instead. Discussion ---------- Replace PHPDoc dataProvider with attribute syntax The attribute syntax is supported in PHPUnit v10, v11, and v12. It should be encouraged in Symfony 8.x, and maybe backport to Symfony 7.x? <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `7.x` for features of unreleased versions). --> Commits ------- 6cc5b9c Replace PHPDoc dataProvider with attribute syntax
2 parents 3b6b704 + 6cc5b9c commit c4c2cf1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

best_practices.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,12 @@ checks that all application URLs load successfully::
403403
// tests/ApplicationAvailabilityFunctionalTest.php
404404
namespace App\Tests;
405405

406+
use PHPUnit\Framework\Attributes\DataProvider;
406407
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
407-
408+
408409
class ApplicationAvailabilityFunctionalTest extends WebTestCase
409410
{
410-
/**
411-
* @dataProvider urlProvider
412-
*/
411+
#[DataProvider('urlProvider')]
413412
public function testPageIsSuccessful($url): void
414413
{
415414
$client = self::createClient();
@@ -418,7 +417,7 @@ checks that all application URLs load successfully::
418417
$this->assertResponseIsSuccessful();
419418
}
420419

421-
public function urlProvider(): \Generator
420+
public static function urlProvider(): \Generator
422421
{
423422
yield ['/'];
424423
yield ['/posts'];

0 commit comments

Comments
 (0)