Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,12 @@
// tests/ApplicationAvailabilityFunctionalTest.php
namespace App\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class ApplicationAvailabilityFunctionalTest extends WebTestCase
{
/**
* @dataProvider urlProvider
*/
#[DataProvider('urlProvider')]
public function testPageIsSuccessful($url): void
{
$client = self::createClient();
Expand All @@ -433,6 +432,11 @@
}
}

.. note::

The ``#[DataProvider]`` attribute is available in PHPUnit 10 and later versions.
In previous versions, use the ``@dataPRovider`` PHPdoc annotation.

Check failure on line 438 in best_practices.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please replace "PHPdoc" with "PHPDoc"

Add this test while creating your application because it requires little effort
and checks that none of your pages returns an error. Later, you'll add more
specific tests for each page.
Expand Down
5 changes: 2 additions & 3 deletions validation/custom_constraint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ class to simplify writing unit tests for your custom constraints::

use App\Validator\ContainsAlphanumeric;
use App\Validator\ContainsAlphanumericValidator;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

Expand All @@ -530,9 +531,7 @@ class to simplify writing unit tests for your custom constraints::
$this->assertNoViolation();
}

/**
* @dataProvider provideInvalidConstraints
*/
#[DataProvider('provideInvalidConstraints')]
public function testTrueIsInvalid(ContainsAlphanumeric $constraint): void
{
$this->validator->validate('...', $constraint);
Expand Down
Loading