From 8eff2aff40cc79f87588b06fe1444d63eeb4facb Mon Sep 17 00:00:00 2001 From: Laurent Muller Date: Mon, 27 May 2024 07:38:34 +0200 Subject: [PATCH] Added composer diff CI. Imported DataProvider attribute. --- .github/workflows/composer_diff.yaml | 35 +++++++++++++++++++ public/js/application/commands.js | 16 ++++----- resources/schema/swiss_city.sql | 2 +- .../Controller/AbstractControllerTestCase.php | 3 +- tests/Controller/AjaxUserControllerTest.php | 7 ++-- .../AddressTransformerTest.php | 5 +-- .../DataTransformer/EntityTransformerTest.php | 5 +-- tests/Entity/AbstractEntityTest.php | 3 +- tests/Entity/ProductTest.php | 3 +- tests/Enums/EntityActionTest.php | 9 ++--- tests/Enums/EntityNameTest.php | 15 ++++---- tests/Enums/EntityPermissionTest.php | 9 ++--- tests/Enums/EnvironmentTest.php | 13 +++---- tests/Enums/FlashTypeTest.php | 11 +++--- tests/Enums/HtmlBootstrapColorTest.php | 11 +++--- tests/Enums/ImageExtensionTest.php | 17 ++++----- tests/Enums/ImageSizeTest.php | 3 +- tests/Enums/ImportanceTest.php | 9 ++--- tests/Enums/MessagePositionTest.php | 13 +++---- tests/Enums/StrengthLevelTest.php | 11 +++--- tests/Enums/TableViewTest.php | 5 +-- tests/Pdf/HtmlListTypeTest.php | 11 +++--- tests/Pdf/PdfBarScaleTest.php | 3 +- tests/Pdf/PdfBlendModeTest.php | 3 +- tests/Pdf/PdfColorTest.php | 15 ++++---- tests/Security/EntityVoterTest.php | 3 +- tests/Service/AssetVersionServiceTest.php | 5 +-- tests/Service/CountryFlagServiceTest.php | 5 +-- tests/Service/PasswordServiceTest.php | 3 +- tests/Service/PositionServiceTest.php | 11 +++--- tests/Service/ProductUpdateServiceTest.php | 5 +-- tests/Service/ThemeServiceTest.php | 7 ++-- tests/Service/UrlGeneratorServiceTest.php | 9 ++--- tests/Service/UserExceptionServiceTest.php | 3 +- tests/Service/UserNamerTest.php | 3 +- tests/Traits/ArrayTraitTest.php | 13 +++---- tests/Traits/CacheKeyTraitTest.php | 3 +- tests/Traits/CheckSubClassTraitTest.php | 3 +- tests/Traits/ImageSizeTraitTest.php | 3 +- tests/Traits/MathTraitTest.php | 15 ++++---- tests/Traits/RightsTraitTest.php | 9 ++--- tests/Traits/RoleTranslatorTraitTest.php | 5 +-- .../StrengthLevelTranslatorTraitTest.php | 3 +- tests/Twig/ConstantExtensionTest.php | 5 +-- tests/Types/FixedFloatTypeTest.php | 3 +- tests/Utils/DateUtilsTest.php | 23 ++++++------ tests/Utils/FileUtilsTest.php | 9 ++--- tests/Utils/FormatUtilsTest.php | 17 ++++----- tests/Utils/StringUtilsTest.php | 19 +++++----- tests/Validator/PasswordValidatorTest.php | 11 +++--- tests/Validator/RecaptchaValidatorTest.php | 3 +- tests/Validator/StrengthValidatorTest.php | 9 ++--- tests/Web/DatabaseTest.php | 7 ++-- tests/Web/RoutesTest.php | 3 +- tests/Web/UsersTest.php | 6 ++-- 55 files changed, 274 insertions(+), 186 deletions(-) create mode 100644 .github/workflows/composer_diff.yaml diff --git a/.github/workflows/composer_diff.yaml b/.github/workflows/composer_diff.yaml new file mode 100644 index 000000000..3dbe7a423 --- /dev/null +++ b/.github/workflows/composer_diff.yaml @@ -0,0 +1,35 @@ +name: Composer Diff + +on: + push: + paths: + - 'composer.lock' + pull_request: + paths: + - 'composer.lock' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate composer diff + id: composer_diff + uses: IonBazan/composer-diff-action@v1 + + - uses: marocchino/sticky-pull-request-comment@v2 + if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }} + with: + header: composer-diff + message: | +
+ Composer package changes + + ${{ steps.composer_diff.outputs.composer_diff }} + +
diff --git a/public/js/application/commands.js b/public/js/application/commands.js index e8f7d71ca..df2ca7ac0 100644 --- a/public/js/application/commands.js +++ b/public/js/application/commands.js @@ -21,6 +21,14 @@ function createPopover() { }); } +function updateExecute() { + 'use strict'; + const $command = $('#command'); + const $execute = $('.btn-execute'); + const href = $execute.data('url').replace('query', $command.val()); + $execute.attr('href', href); +} + /** * Load the given command. * @@ -47,14 +55,6 @@ function loadContent(name) { }); } -function updateExecute() { - 'use strict'; - const $command = $('#command'); - const $execute = $('.btn-execute'); - const href = $execute.data('url').replace('query', $command.val()); - $execute.attr('href', href); -} - /** * Ready function */ diff --git a/resources/schema/swiss_city.sql b/resources/schema/swiss_city.sql index cb2666ea6..1dc9da43c 100644 --- a/resources/schema/swiss_city.sql +++ b/resources/schema/swiss_city.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS city zip INTEGER NOT NULL, name TEXT NOT NULL, state_id TEXT NOT NULL -) +); CREATE TABLE IF NOT EXISTS state ( diff --git a/tests/Controller/AbstractControllerTestCase.php b/tests/Controller/AbstractControllerTestCase.php index fda8445de..69bc08a77 100644 --- a/tests/Controller/AbstractControllerTestCase.php +++ b/tests/Controller/AbstractControllerTestCase.php @@ -15,6 +15,7 @@ use App\Controller\AbstractController; use App\Tests\Web\AbstractAuthenticateWebTestCase; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -39,7 +40,7 @@ abstract public static function getRoutes(): \Iterator; * @param int $expected the expected result * @param string $method the request method */ - #[\PHPUnit\Framework\Attributes\DataProvider('getRoutes')] + #[DataProvider('getRoutes')] public function testRoutes( string $url, string $username = '', diff --git a/tests/Controller/AjaxUserControllerTest.php b/tests/Controller/AjaxUserControllerTest.php index c07bcad60..bf4f01f8c 100644 --- a/tests/Controller/AjaxUserControllerTest.php +++ b/tests/Controller/AjaxUserControllerTest.php @@ -15,6 +15,7 @@ use App\Controller\AjaxUserController; use App\Tests\Web\AbstractAuthenticateWebTestCase; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; @@ -53,7 +54,7 @@ public static function getUsers(): \Iterator yield ['username.not_found', 'USER_XXX_INVALID@INVALID.COM']; } - #[\PHPUnit\Framework\Attributes\DataProvider('getEmails')] + #[DataProvider('getEmails')] public function testCheckEmail(string|bool $expected, ?string $email = null, ?int $id = null): void { $this->loginUsername('ROLE_SUPER_ADMIN'); @@ -63,7 +64,7 @@ public function testCheckEmail(string|bool $expected, ?string $email = null, ?in $this->validateResponse($response, $expected); } - #[\PHPUnit\Framework\Attributes\DataProvider('getNames')] + #[DataProvider('getNames')] public function testCheckName(string|bool $expected, ?string $username = null, ?int $id = null): void { $this->loginUsername('ROLE_SUPER_ADMIN'); @@ -73,7 +74,7 @@ public function testCheckName(string|bool $expected, ?string $username = null, ? $this->validateResponse($response, $expected); } - #[\PHPUnit\Framework\Attributes\DataProvider('getUsers')] + #[DataProvider('getUsers')] public function testCheckUser(string|bool $expected, ?string $user = null): void { $parameters = ['user' => $user]; diff --git a/tests/DataTransformer/AddressTransformerTest.php b/tests/DataTransformer/AddressTransformerTest.php index 045d95945..fea32e1e5 100644 --- a/tests/DataTransformer/AddressTransformerTest.php +++ b/tests/DataTransformer/AddressTransformerTest.php @@ -14,6 +14,7 @@ use App\Form\DataTransformer\AddressTransformer; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Mime\Address; @@ -52,7 +53,7 @@ public static function getTransformValues(): \Generator yield [new Address('user@root.com', 'username'), \htmlentities('username ')]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getReverseTransformValues')] + #[DataProvider('getReverseTransformValues')] public function testReverseTransform(mixed $value, mixed $expected, bool $exception = false): void { if ($exception) { @@ -66,7 +67,7 @@ public function testReverseTransform(mixed $value, mixed $expected, bool $except } } - #[\PHPUnit\Framework\Attributes\DataProvider('getTransformValues')] + #[DataProvider('getTransformValues')] public function testTransform(mixed $value, mixed $expected, bool $exception = false): void { if ($exception) { diff --git a/tests/DataTransformer/EntityTransformerTest.php b/tests/DataTransformer/EntityTransformerTest.php index 4c90ebca6..25624d9ab 100644 --- a/tests/DataTransformer/EntityTransformerTest.php +++ b/tests/DataTransformer/EntityTransformerTest.php @@ -18,6 +18,7 @@ use App\Repository\GroupRepository; use App\Tests\Entity\IdTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; @@ -49,7 +50,7 @@ public static function getTransformValues(): \Generator * * @throws Exception|\ReflectionException */ - #[\PHPUnit\Framework\Attributes\DataProvider('getReverseTransformValues')] + #[DataProvider('getReverseTransformValues')] public function testReverseTransform(mixed $value, mixed $expected, bool $exception = false): void { $group = null; @@ -83,7 +84,7 @@ public function testReverseTransformGroup(): void * * @throws Exception|\ReflectionException */ - #[\PHPUnit\Framework\Attributes\DataProvider('getTransformValues')] + #[DataProvider('getTransformValues')] public function testTransform(mixed $value, mixed $expected, bool $exception = false): void { $group = null; diff --git a/tests/Entity/AbstractEntityTest.php b/tests/Entity/AbstractEntityTest.php index 8d0022ba4..20641228f 100644 --- a/tests/Entity/AbstractEntityTest.php +++ b/tests/Entity/AbstractEntityTest.php @@ -14,6 +14,7 @@ use App\Entity\AbstractEntity; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(AbstractEntity::class)] @@ -78,7 +79,7 @@ public function testIsNew(): void * * @psalm-suppress InaccessibleMethod */ - #[\PHPUnit\Framework\Attributes\DataProvider('getTrims')] + #[DataProvider('getTrims')] public function testTrim(?string $value, ?string $expected): void { $entity = $this->getEntity(); diff --git a/tests/Entity/ProductTest.php b/tests/Entity/ProductTest.php index 669505e69..d14c1aae8 100644 --- a/tests/Entity/ProductTest.php +++ b/tests/Entity/ProductTest.php @@ -16,6 +16,7 @@ use App\Entity\Group; use App\Entity\Product; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(Product::class)] class ProductTest extends AbstractEntityValidatorTestCase @@ -160,7 +161,7 @@ public function testNotDuplicate(): void } } - #[\PHPUnit\Framework\Attributes\DataProvider('getPrices')] + #[DataProvider('getPrices')] public function testPrice(float $price, float $expected): void { $product = new Product(); diff --git a/tests/Enums/EntityActionTest.php b/tests/Enums/EntityActionTest.php index 642414b53..ef27678dd 100644 --- a/tests/Enums/EntityActionTest.php +++ b/tests/Enums/EntityActionTest.php @@ -16,6 +16,7 @@ use App\Interfaces\PropertyServiceInterface; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -51,13 +52,13 @@ public function testCount(): void self::assertCount($expected, EntityAction::sorted()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getDefault')] + #[DataProvider('getDefault')] public function testDefault(EntityAction $value, EntityAction $expected): void { self::assertSame($expected, $value); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testLabel(string $expected, EntityAction $action): void { $actual = $action->getReadable(); @@ -78,7 +79,7 @@ public function testSorted(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testTranslate(string $expected, EntityAction $action): void { $translator = $this->createTranslator(); @@ -86,7 +87,7 @@ public function testTranslate(string $expected, EntityAction $action): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValue(EntityAction $action, string $expected): void { $actual = $action->value; diff --git a/tests/Enums/EntityNameTest.php b/tests/Enums/EntityNameTest.php index eb7dc614f..8296d17d1 100644 --- a/tests/Enums/EntityNameTest.php +++ b/tests/Enums/EntityNameTest.php @@ -26,6 +26,7 @@ use App\Model\Role; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -167,21 +168,21 @@ public function testCount(): void self::assertCount($expected, EntityName::sorted()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testLabel(string $expected, EntityName $entity): void { $actual = $entity->getReadable(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getOffset')] + #[DataProvider('getOffset')] public function testOffset(EntityName $entityName, int $expected): void { $actual = $entityName->offset(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRightsField')] + #[DataProvider('getRightsField')] public function testRightsField(EntityName $entityName, string $expected): void { $actual = $entityName->getRightsField(); @@ -209,7 +210,7 @@ public function testSorted(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testTranslate(string $expected, EntityName $entity): void { $translator = $this->createTranslator(); @@ -217,7 +218,7 @@ public function testTranslate(string $expected, EntityName $entity): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getTryFromField')] + #[DataProvider('getTryFromField')] public function testTryFromField(string $field, ?EntityName $expected): void { $actual = EntityName::tryFromField($field); @@ -228,14 +229,14 @@ public function testTryFromField(string $field, ?EntityName $expected): void } } - #[\PHPUnit\Framework\Attributes\DataProvider('getTryFromMixed')] + #[DataProvider('getTryFromMixed')] public function testTryFromMixed(mixed $subject, mixed $expected): void { $actual = EntityName::tryFromMixed($subject); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValue')] + #[DataProvider('getValue')] public function testValue(EntityName $entityName, string $expected): void { $actual = $entityName->value; diff --git a/tests/Enums/EntityPermissionTest.php b/tests/Enums/EntityPermissionTest.php index 5b5523e11..f84234b4c 100644 --- a/tests/Enums/EntityPermissionTest.php +++ b/tests/Enums/EntityPermissionTest.php @@ -16,6 +16,7 @@ use App\Tests\TranslatorMockTrait; use Elao\Enum\FlagBag; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -121,7 +122,7 @@ public function testDefaultPermission(): void } } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testLabel(EntityPermission $permission, string $expected): void { $actual = $permission->getReadable(); @@ -161,7 +162,7 @@ public function testSum(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testTranslate(EntityPermission $permission, string $expected): void { $translator = $this->createTranslator(); @@ -169,14 +170,14 @@ public function testTranslate(EntityPermission $permission, string $expected): v self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getTryFromName')] + #[DataProvider('getTryFromName')] public function testTryFromName(mixed $expected, string $value): void { $actual = EntityPermission::tryFromName($value); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValue')] + #[DataProvider('getValue')] public function testValue(EntityPermission $permission, int $expected): void { $actual = $permission->value; diff --git a/tests/Enums/EnvironmentTest.php b/tests/Enums/EnvironmentTest.php index 91bd63f63..31c044afa 100644 --- a/tests/Enums/EnvironmentTest.php +++ b/tests/Enums/EnvironmentTest.php @@ -15,6 +15,7 @@ use App\Enums\Environment; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -65,28 +66,28 @@ public function testCount(): void self::assertCount($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsDevelopment')] + #[DataProvider('getIsDevelopment')] public function testIsDevelopment(Environment $environment, bool $expected): void { $actual = $environment->isDevelopment(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsProduction')] + #[DataProvider('getIsProduction')] public function testIsProduction(Environment $environment, bool $expected): void { $actual = $environment->isProduction(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsTest')] + #[DataProvider('getIsTest')] public function testIsTest(Environment $environment, bool $expected): void { $actual = $environment->isTest(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testLabel(Environment $environment, string $expected): void { $actual = $environment->getReadable(); @@ -96,7 +97,7 @@ public function testLabel(Environment $environment, string $expected): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testTranslate(Environment $environment, string $expected): void { $translator = $this->createTranslator(); @@ -104,7 +105,7 @@ public function testTranslate(Environment $environment, string $expected): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValue(Environment $environment, string $expected): void { $actual = $environment->value; diff --git a/tests/Enums/FlashTypeTest.php b/tests/Enums/FlashTypeTest.php index 8b2fc6ca9..b6efc34bc 100644 --- a/tests/Enums/FlashTypeTest.php +++ b/tests/Enums/FlashTypeTest.php @@ -15,6 +15,7 @@ use App\Enums\FlashType; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -60,21 +61,21 @@ public function testCount(): void self::assertCount(4, FlashType::cases()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIcons')] + #[DataProvider('getIcons')] public function testIcon(FlashType $type, string $expected): void { $actual = $type->getIcon(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testLabel(FlashType $type, string $expected): void { $actual = $type->getReadable(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getStyles')] + #[DataProvider('getStyles')] public function testStyle(FlashType $type, string $expected): void { $actual = $type->getStyle(); @@ -84,7 +85,7 @@ public function testStyle(FlashType $type, string $expected): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testTranslate(FlashType $type, string $expected): void { $translator = $this->createTranslator(); @@ -92,7 +93,7 @@ public function testTranslate(FlashType $type, string $expected): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValue(FlashType $type, string $expected): void { $actual = $type->value; diff --git a/tests/Enums/HtmlBootstrapColorTest.php b/tests/Enums/HtmlBootstrapColorTest.php index 59354aed5..63e94e928 100644 --- a/tests/Enums/HtmlBootstrapColorTest.php +++ b/tests/Enums/HtmlBootstrapColorTest.php @@ -17,6 +17,7 @@ use App\Pdf\Colors\PdfTextColor; use App\Pdf\Html\HtmlBootstrapColor; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(HtmlBootstrapColor::class)] @@ -116,7 +117,7 @@ public function testFillColor(): void $this->handleColors(static fn (HtmlBootstrapColor $color): PdfFillColor => $color->getFillColor()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getParseBorderColors')] + #[DataProvider('getParseBorderColors')] public function testParseBorderColor(string $class, ?HtmlBootstrapColor $color): void { $actual = HtmlBootstrapColor::parseBorderColor($class); @@ -128,7 +129,7 @@ public function testParseBorderColor(string $class, ?HtmlBootstrapColor $color): } } - #[\PHPUnit\Framework\Attributes\DataProvider('getParseFillColors')] + #[DataProvider('getParseFillColors')] public function testParseFillColor(string $class, ?HtmlBootstrapColor $color): void { $actual = HtmlBootstrapColor::parseFillColor($class); @@ -140,7 +141,7 @@ public function testParseFillColor(string $class, ?HtmlBootstrapColor $color): v } } - #[\PHPUnit\Framework\Attributes\DataProvider('getParseTextColors')] + #[DataProvider('getParseTextColors')] public function testParseTextColor(string $class, ?HtmlBootstrapColor $color): void { $actual = HtmlBootstrapColor::parseTextColor($class); @@ -152,7 +153,7 @@ public function testParseTextColor(string $class, ?HtmlBootstrapColor $color): v } } - #[\PHPUnit\Framework\Attributes\DataProvider('getPhpOfficeColors')] + #[DataProvider('getPhpOfficeColors')] public function testPhpOfficeColor(HtmlBootstrapColor $color, string $expected): void { $actual = $color->getPhpOfficeColor(); @@ -164,7 +165,7 @@ public function testTextColor(): void $this->handleColors(static fn (HtmlBootstrapColor $color): PdfTextColor => $color->getTextColor()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getColorValues')] + #[DataProvider('getColorValues')] public function testValue(HtmlBootstrapColor $color, string $expected): void { $actual = $color->value; diff --git a/tests/Enums/ImageExtensionTest.php b/tests/Enums/ImageExtensionTest.php index 5d3e65777..1be783d84 100644 --- a/tests/Enums/ImageExtensionTest.php +++ b/tests/Enums/ImageExtensionTest.php @@ -16,6 +16,7 @@ use App\Service\ImageService; use App\Utils\FileUtils; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(ImageExtension::class)] @@ -133,7 +134,7 @@ public function testCount(): void self::assertCount(9, ImageExtension::cases()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getCreateImages')] + #[DataProvider('getCreateImages')] public function testCreateImage(ImageExtension $extension, string $filename): void { if (!\file_exists($filename)) { @@ -152,14 +153,14 @@ public function testDefault(): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getFilters')] + #[DataProvider('getFilters')] public function testFilter(ImageExtension $imageExtension, string $expected): void { $actual = $imageExtension->getFilter(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getImageTypes')] + #[DataProvider('getImageTypes')] public function testImageType(ImageExtension $extension, int $expected): void { $actual = $extension->getImageType(); @@ -173,7 +174,7 @@ public function testImageType(ImageExtension $extension, int $expected): void * filters?: int, * foreground_color?: int|null} $options */ - #[\PHPUnit\Framework\Attributes\DataProvider('getInvalidOptions')] + #[DataProvider('getInvalidOptions')] public function testInvalidOptions(ImageExtension $extension, array $options): void { self::expectException(\RuntimeException::class); @@ -204,14 +205,14 @@ public function testSaveImageService(): void } } - #[\PHPUnit\Framework\Attributes\DataProvider('getTryFromTypes')] + #[DataProvider('getTryFromTypes')] public function testTryFromType(int $type, ?ImageExtension $expected = null): void { $actual = ImageExtension::tryFromType($type); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getTypes')] + #[DataProvider('getTypes')] public function testType(ImageExtension $extension, int $expected): void { $actual = $extension->getImageType(); @@ -225,7 +226,7 @@ public function testType(ImageExtension $extension, int $expected): void * filters?: int, * foreground_color?: int|null} $options */ - #[\PHPUnit\Framework\Attributes\DataProvider('getValidOptions')] + #[DataProvider('getValidOptions')] public function testValidOptions(ImageExtension $extension, array $options, bool $expected = true): void { $image = \imagecreatetruecolor(100, 100); @@ -243,7 +244,7 @@ public function testValidOptions(ImageExtension $extension, array $options, bool } } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValues(ImageExtension $imageExtension, string $expected): void { $actual = $imageExtension->value; diff --git a/tests/Enums/ImageSizeTest.php b/tests/Enums/ImageSizeTest.php index 12dcf9e19..0da184d7a 100644 --- a/tests/Enums/ImageSizeTest.php +++ b/tests/Enums/ImageSizeTest.php @@ -14,6 +14,7 @@ use App\Enums\ImageSize; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(ImageSize::class)] @@ -38,7 +39,7 @@ public function testDefault(): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValue(ImageSize $imageSize, int $expected): void { $actual = $imageSize->value; diff --git a/tests/Enums/ImportanceTest.php b/tests/Enums/ImportanceTest.php index 603d1cf5c..549f7acca 100644 --- a/tests/Enums/ImportanceTest.php +++ b/tests/Enums/ImportanceTest.php @@ -15,6 +15,7 @@ use App\Enums\Importance; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -60,14 +61,14 @@ public function testDefault(): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testLabel(string $expected, Importance $importance): void { $actual = $importance->getReadable(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabelsFull')] + #[DataProvider('getLabelsFull')] public function testLabelFull(string $expected, Importance $importance): void { $actual = $importance->getReadableFull(); @@ -89,7 +90,7 @@ public function testSorted(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testTranslate(string $expected, Importance $importance): void { $translator = $this->createTranslator(); @@ -97,7 +98,7 @@ public function testTranslate(string $expected, Importance $importance): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValue(Importance $importance, string $expected): void { $actual = $importance->value; diff --git a/tests/Enums/MessagePositionTest.php b/tests/Enums/MessagePositionTest.php index 9d69e1a7b..9ee2e9460 100644 --- a/tests/Enums/MessagePositionTest.php +++ b/tests/Enums/MessagePositionTest.php @@ -16,6 +16,7 @@ use App\Interfaces\PropertyServiceInterface; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -82,7 +83,7 @@ public static function getTranslation(): \Iterator yield [MessagePosition::BOTTOM_RIGHT, 'message_position.bottom-right']; } - #[\PHPUnit\Framework\Attributes\DataProvider('getAngle')] + #[DataProvider('getAngle')] public function testAngle(MessagePosition $position, int $expected): void { $actual = $position->getAngle(); @@ -96,20 +97,20 @@ public function testCount(): void self::assertCount($expected, MessagePosition::sorted()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getDefault')] + #[DataProvider('getDefault')] public function testDefault(MessagePosition $value, MessagePosition $expected): void { self::assertSame($expected, $value); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIcon')] + #[DataProvider('getIcon')] public function testIcon(MessagePosition $position, string $expected): void { $actual = $position->getIcon(); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testLabel(MessagePosition $position, string $value): void { $expected = 'message_position.' . $value; @@ -139,7 +140,7 @@ public function testSorted(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getTranslation')] + #[DataProvider('getTranslation')] public function testTranslate(MessagePosition $position, string $expected): void { $translator = $this->createTranslator(); @@ -147,7 +148,7 @@ public function testTranslate(MessagePosition $position, string $expected): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabel')] + #[DataProvider('getLabel')] public function testValue(MessagePosition $position, string $expected): void { $actual = $position->value; diff --git a/tests/Enums/StrengthLevelTest.php b/tests/Enums/StrengthLevelTest.php index cebef265d..8f477068b 100644 --- a/tests/Enums/StrengthLevelTest.php +++ b/tests/Enums/StrengthLevelTest.php @@ -16,6 +16,7 @@ use App\Interfaces\PropertyServiceInterface; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -69,13 +70,13 @@ public function testCount(): void self::assertCount($expected, StrengthLevel::sorted()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getDefault')] + #[DataProvider('getDefault')] public function testDefault(StrengthLevel $value, StrengthLevel $expected): void { self::assertSame($expected, $value); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testLabel(string $expected, StrengthLevel $level): void { $actual = $level->getReadable(); @@ -92,7 +93,7 @@ public function testPercent(): void self::assertSame(100, StrengthLevel::VERY_STRONG->percent()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getSmallerValues')] + #[DataProvider('getSmallerValues')] public function testSmaller(StrengthLevel $level, int|StrengthLevel $other, bool $expected): void { $actual = $level->isSmaller($other); @@ -116,7 +117,7 @@ public function testSorted(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLabels')] + #[DataProvider('getLabels')] public function testTranslate(string $expected, StrengthLevel $level): void { $translator = $this->createTranslator(); @@ -124,7 +125,7 @@ public function testTranslate(string $expected, StrengthLevel $level): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValue(StrengthLevel $level, int $expected): void { $actual = $level->value; diff --git a/tests/Enums/TableViewTest.php b/tests/Enums/TableViewTest.php index 269d064b3..cf70581ea 100644 --- a/tests/Enums/TableViewTest.php +++ b/tests/Enums/TableViewTest.php @@ -16,6 +16,7 @@ use App\Interfaces\PropertyServiceInterface; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -43,7 +44,7 @@ public function testCount(): void self::assertCount($expected, TableView::sorted()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getDefault')] + #[DataProvider('getDefault')] public function testDefault(TableView $value, TableView $expected): void { self::assertSame($expected, $value); @@ -81,7 +82,7 @@ public function testTranslate(): void self::assertSame('table_view.table', TableView::TABLE->trans($translator)); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testValue(TableView $view, string $expected): void { $actual = $view->value; diff --git a/tests/Pdf/HtmlListTypeTest.php b/tests/Pdf/HtmlListTypeTest.php index 047700823..3ac71db4d 100644 --- a/tests/Pdf/HtmlListTypeTest.php +++ b/tests/Pdf/HtmlListTypeTest.php @@ -14,6 +14,7 @@ use App\Pdf\Html\HtmlListType; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(HtmlListType::class)] @@ -78,35 +79,35 @@ public static function getRomanValues(): \Iterator yield [3999, 'MMMCMXCIX']; } - #[\PHPUnit\Framework\Attributes\DataProvider('getLetterValues')] + #[DataProvider('getLetterValues')] public function testLetterLower(int $value, string $expected, string $suffix = ''): void { $actual = HtmlListType::LETTER_LOWER->getBulletText($value, $suffix); self::assertSame(\strtolower($expected), $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getLetterValues')] + #[DataProvider('getLetterValues')] public function testLetterUpper(int $value, string $expected, string $suffix = ''): void { $actual = HtmlListType::LETTER_UPPER->getBulletText($value, $suffix); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getNumberValues')] + #[DataProvider('getNumberValues')] public function testNumber(int $value, string $expected, string $suffix = ''): void { $actual = HtmlListType::NUMBER->getBulletText($value, $suffix); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRomanValues')] + #[DataProvider('getRomanValues')] public function testRomanLower(int $value, string $expected, string $suffix = ''): void { $actual = HtmlListType::ROMAN_LOWER->getBulletText($value, $suffix); self::assertSame(\strtolower($expected), $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRomanValues')] + #[DataProvider('getRomanValues')] public function testRomanUpper(int $value, string $expected, string $suffix = ''): void { $actual = HtmlListType::ROMAN_UPPER->getBulletText($value, $suffix); diff --git a/tests/Pdf/PdfBarScaleTest.php b/tests/Pdf/PdfBarScaleTest.php index e7503dd4a..f0671df28 100644 --- a/tests/Pdf/PdfBarScaleTest.php +++ b/tests/Pdf/PdfBarScaleTest.php @@ -14,6 +14,7 @@ use App\Pdf\PdfBarScale; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(PdfBarScale::class)] @@ -75,7 +76,7 @@ public function testProperties(): void self::assertSame(10.0, $actual->getTickSpacing()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testScale(PdfBarScale $scale, float $lowerBound, float $upperBound, float $tickSpacing): void { self::assertSame($lowerBound, $scale->getLowerBound()); diff --git a/tests/Pdf/PdfBlendModeTest.php b/tests/Pdf/PdfBlendModeTest.php index ed6fd2f11..54d365357 100644 --- a/tests/Pdf/PdfBlendModeTest.php +++ b/tests/Pdf/PdfBlendModeTest.php @@ -14,6 +14,7 @@ use App\Pdf\Enums\PdfBlendMode; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(PdfBlendMode::class)] @@ -27,7 +28,7 @@ public static function getModes(): \Generator } } - #[\PHPUnit\Framework\Attributes\DataProvider('getModes')] + #[DataProvider('getModes')] public function testCamel(PdfBlendMode $mode): void { $actual = $mode->camel(); diff --git a/tests/Pdf/PdfColorTest.php b/tests/Pdf/PdfColorTest.php index 3dcef804d..7ca05dc84 100644 --- a/tests/Pdf/PdfColorTest.php +++ b/tests/Pdf/PdfColorTest.php @@ -18,6 +18,7 @@ use App\Pdf\Colors\PdfTextColor; use App\Pdf\PdfDocument; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(AbstractPdfColor::class)] @@ -132,7 +133,7 @@ public function testApply(): void * @psalm-param int<0, 255> $green * @psalm-param int<0, 255> $blue */ - #[\PHPUnit\Framework\Attributes\DataProvider('getHexColors')] + #[DataProvider('getHexColors')] public function testAsHex(int $red, int $green, int $blue, string $expected, string $prefix = ''): void { $color = new PdfDrawColor($red, $green, $blue); @@ -145,7 +146,7 @@ public function testAsHex(int $red, int $green, int $blue, string $expected, str * @psalm-param int<0, 255> $green * @psalm-param int<0, 255> $blue */ - #[\PHPUnit\Framework\Attributes\DataProvider('getIntColors')] + #[DataProvider('getIntColors')] public function testAsInt(int $red, int $green, int $blue, int $expected): void { $color = new PdfDrawColor($red, $green, $blue); @@ -220,7 +221,7 @@ public function testDefaultColors(): void self::assertEqualColor(PdfTextColor::black(), PdfTextColor::default()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getNamedColors')] + #[DataProvider('getNamedColors')] public function testDrawColor(string $name, int $red, int $green, int $blue): void { /** @var PdfDrawColor $color */ @@ -228,7 +229,7 @@ public function testDrawColor(string $name, int $red, int $green, int $blue): vo self::assertEqualValues($color, $red, $green, $blue); } - #[\PHPUnit\Framework\Attributes\DataProvider('getNamedColors')] + #[DataProvider('getNamedColors')] public function testFillColor(string $name, int $red, int $green, int $blue): void { /** @var PdfFillColor $color */ @@ -239,7 +240,7 @@ public function testFillColor(string $name, int $red, int $green, int $blue): vo /** * @psalm-param int<0, 255>[]|int|string|null $rgb */ - #[\PHPUnit\Framework\Attributes\DataProvider('getInvalidColors')] + #[DataProvider('getInvalidColors')] public function testInvalidColors(array|int|string|null $rgb): void { $color = PdfTextColor::create($rgb); @@ -254,7 +255,7 @@ public function testIsFillColor(): void self::assertFalse($fill->isFillColor()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getNamedColors')] + #[DataProvider('getNamedColors')] public function testTextColor(string $name, int $red, int $green, int $blue): void { /** @var PdfTextColor $color */ @@ -265,7 +266,7 @@ public function testTextColor(string $name, int $red, int $green, int $blue): vo /** * @psalm-param int<0, 255>[]|int|string|null $rgb */ - #[\PHPUnit\Framework\Attributes\DataProvider('getValidColors')] + #[DataProvider('getValidColors')] public function testValidColors(array|int|string|null $rgb, int $red, int $green, int $blue): void { $color = PdfTextColor::create($rgb); diff --git a/tests/Security/EntityVoterTest.php b/tests/Security/EntityVoterTest.php index 8a6830c56..b9579e712 100644 --- a/tests/Security/EntityVoterTest.php +++ b/tests/Security/EntityVoterTest.php @@ -19,6 +19,7 @@ use App\Service\ApplicationService; use App\Service\RoleBuilderService; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; @@ -95,7 +96,7 @@ public function testSuperAdmin(): void $this->assertVote($user, $subject, $attribute, $expected); } - #[\PHPUnit\Framework\Attributes\DataProvider('getSupportsAttribute')] + #[DataProvider('getSupportsAttribute')] public function testSupportsAttribute(string $value, bool $expected): void { $actual = $this->voter->supportsAttribute($value); diff --git a/tests/Service/AssetVersionServiceTest.php b/tests/Service/AssetVersionServiceTest.php index da8bfbcb1..f81d5fdb3 100644 --- a/tests/Service/AssetVersionServiceTest.php +++ b/tests/Service/AssetVersionServiceTest.php @@ -15,6 +15,7 @@ use App\Enums\Environment; use App\Service\AssetVersionService; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Cache\InvalidArgumentException; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -53,7 +54,7 @@ public static function getPaths(): \Iterator yield ['images/users/fake.png', true]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getPaths')] + #[DataProvider('getPaths')] public function testApplyVersion(string $path, bool $isImage = false): void { $version = $this->getVersion($isImage); @@ -65,7 +66,7 @@ public function testApplyVersion(string $path, bool $isImage = false): void /** * @throws InvalidArgumentException */ - #[\PHPUnit\Framework\Attributes\DataProvider('getPaths')] + #[DataProvider('getPaths')] public function testPath(string $path, bool $isImage = false): void { $expected = $this->getVersion($isImage); diff --git a/tests/Service/CountryFlagServiceTest.php b/tests/Service/CountryFlagServiceTest.php index 5b4d48be2..b0e275013 100644 --- a/tests/Service/CountryFlagServiceTest.php +++ b/tests/Service/CountryFlagServiceTest.php @@ -14,6 +14,7 @@ use App\Service\CountryFlagService; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Intl\Countries; @@ -56,7 +57,7 @@ public function testChoices(): void self::assertCount($expected, $choices); } - #[\PHPUnit\Framework\Attributes\DataProvider('getDefaultCodes')] + #[DataProvider('getDefaultCodes')] public function testDefaultCode(string $locale, string $expected): void { \Locale::setDefault($locale); @@ -64,7 +65,7 @@ public function testDefaultCode(string $locale, string $expected): void self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getFlags')] + #[DataProvider('getFlags')] public function testGetFlag(string $alpha2Code, string $expected, bool $validate = true, bool $exception = false): void { if ($exception) { diff --git a/tests/Service/PasswordServiceTest.php b/tests/Service/PasswordServiceTest.php index cef8162f9..c8e3f770b 100644 --- a/tests/Service/PasswordServiceTest.php +++ b/tests/Service/PasswordServiceTest.php @@ -19,6 +19,7 @@ use App\Tests\TranslatorMockTrait; use Createnl\ZxcvbnBundle\ZxcvbnFactoryInterface; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use ZxcvbnPhp\Zxcvbn; @@ -79,7 +80,7 @@ public function testCustom(): void self::assertFalse($actual['result']); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValidations')] + #[DataProvider('getValidations')] public function testValidate(string $password, StrengthLevel $level, bool $expected): void { $query = new PasswordQuery($password, $level); diff --git a/tests/Service/PositionServiceTest.php b/tests/Service/PositionServiceTest.php index c81e89ba9..36597c5d5 100644 --- a/tests/Service/PositionServiceTest.php +++ b/tests/Service/PositionServiceTest.php @@ -15,6 +15,7 @@ use App\Service\PositionService; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; @@ -85,7 +86,7 @@ public static function getPositions(): \Iterator /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getFormatDirections')] + #[DataProvider('getFormatDirections')] public function testFormatDirection(int $deg, string $expected): void { $service = $this->createService(); @@ -96,7 +97,7 @@ public function testFormatDirection(int $deg, string $expected): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLatitudes')] + #[DataProvider('getLatitudes')] public function testFormatLatitude(float $lat, string $expected, bool $exception = false): void { if ($exception) { @@ -110,7 +111,7 @@ public function testFormatLatitude(float $lat, string $expected, bool $exception /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getLongitudes')] + #[DataProvider('getLongitudes')] public function testFormatLongitude(float $lng, string $expected, bool $exception = false): void { if ($exception) { @@ -124,7 +125,7 @@ public function testFormatLongitude(float $lng, string $expected, bool $exceptio /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getPositions')] + #[DataProvider('getPositions')] public function testFormatPosition(float $lat, float $lng, string $expected, bool $exception = false): void { if ($exception) { @@ -138,7 +139,7 @@ public function testFormatPosition(float $lat, float $lng, string $expected, boo /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getDirections')] + #[DataProvider('getDirections')] public function testGetDirection(float $deg, string $expected): void { $service = $this->createService(); diff --git a/tests/Service/ProductUpdateServiceTest.php b/tests/Service/ProductUpdateServiceTest.php index 5c7107f29..3ee75d670 100644 --- a/tests/Service/ProductUpdateServiceTest.php +++ b/tests/Service/ProductUpdateServiceTest.php @@ -23,6 +23,7 @@ use App\Tests\Entity\IdTrait; use App\Tests\TranslatorMockTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; @@ -131,7 +132,7 @@ public function testEmptyProducts(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getFixedRounded')] + #[DataProvider('getFixedRounded')] public function testFixedRounded(float $price, float $expected, float $fixed = 1.0): void { $this->product->setPrice($price); @@ -188,7 +189,7 @@ public function testGetAllProducts(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getPercentRounded')] + #[DataProvider('getPercentRounded')] public function testPercentRounded(float $price, float $percent, float $expected): void { $this->product->setPrice($price); diff --git a/tests/Service/ThemeServiceTest.php b/tests/Service/ThemeServiceTest.php index 88df26890..235e0d6b9 100644 --- a/tests/Service/ThemeServiceTest.php +++ b/tests/Service/ThemeServiceTest.php @@ -15,6 +15,7 @@ use App\Enums\Theme; use App\Service\ThemeService; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -46,7 +47,7 @@ public static function getThemeValues(): \Generator yield [self::createRequest('light'), 'light']; } - #[\PHPUnit\Framework\Attributes\DataProvider('getThemes')] + #[DataProvider('getThemes')] public function testGetTheme(Request $request, Theme $expected): void { $service = new ThemeService(); @@ -61,7 +62,7 @@ public function testGetThemes(): void self::assertSame(Theme::sorted(), $themes); } - #[\PHPUnit\Framework\Attributes\DataProvider('getThemeValues')] + #[DataProvider('getThemeValues')] public function testGetThemeValue(Request $request, string $expected): void { $service = new ThemeService(); @@ -69,7 +70,7 @@ public function testGetThemeValue(Request $request, string $expected): void self::assertSame($expected, $value); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsDarkTheme')] + #[DataProvider('getIsDarkTheme')] public function testIsDarkTheme(Request $request, bool $expected): void { $service = new ThemeService(); diff --git a/tests/Service/UrlGeneratorServiceTest.php b/tests/Service/UrlGeneratorServiceTest.php index 3e3e74b8e..74bc02d26 100644 --- a/tests/Service/UrlGeneratorServiceTest.php +++ b/tests/Service/UrlGeneratorServiceTest.php @@ -18,6 +18,7 @@ use App\Tests\Entity\IdTrait; use App\Tests\KernelServiceTestCase; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\HttpFoundation\Request; #[CoversClass(UrlGeneratorService::class)] @@ -63,21 +64,21 @@ public static function getRouteParams(): \Iterator yield [new Request([]), ['id' => 1], $entity]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getRequests')] + #[DataProvider('getRequests')] public function testCancelUrl(Request $request, string $expected, EntityInterface|int|null $id = 0): void { $actual = $this->service->cancelUrl($request, $id); self::assertStringContainsString($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getGenerates')] + #[DataProvider('getGenerates')] public function testGenerate(string $name, string $expected, array $parameters = []): void { $actual = $this->service->generate($name, $parameters); self::assertStringContainsString($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRequests')] + #[DataProvider('getRequests')] public function testRedirect(Request $request, string $expected, EntityInterface|int|null $id = 0): void { $actual = $this->service->redirect($request, $id); @@ -85,7 +86,7 @@ public function testRedirect(Request $request, string $expected, EntityInterface self::assertStringContainsString($expected, $actual->getTargetUrl()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRouteParams')] + #[DataProvider('getRouteParams')] public function testRouteParams(Request $request, array $expected, EntityInterface|int|null $id = 0): void { $actual = $this->service->routeParams($request, $id); diff --git a/tests/Service/UserExceptionServiceTest.php b/tests/Service/UserExceptionServiceTest.php index 8ff10de72..4bb7d42da 100644 --- a/tests/Service/UserExceptionServiceTest.php +++ b/tests/Service/UserExceptionServiceTest.php @@ -14,6 +14,7 @@ use App\Service\UserExceptionService; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session; @@ -59,7 +60,7 @@ public static function getExceptions(): \Iterator yield [new \Exception(), 'error_unknown']; } - #[\PHPUnit\Framework\Attributes\DataProvider('getExceptions')] + #[DataProvider('getExceptions')] public function testException(\Throwable $e, string $message, int $messageData = 0): void { $result = $this->mapException($e); diff --git a/tests/Service/UserNamerTest.php b/tests/Service/UserNamerTest.php index 710ecd129..31c374ece 100644 --- a/tests/Service/UserNamerTest.php +++ b/tests/Service/UserNamerTest.php @@ -17,6 +17,7 @@ use App\Enums\ImageSize; use App\Service\UserNamer; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Vich\UploaderBundle\Mapping\PropertyMapping; @@ -36,7 +37,7 @@ public static function getBaseNames(): \Iterator yield ['USER_000001_032.png', 1, ImageSize::SMALL, ImageExtension::PNG]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getBaseNames')] + #[DataProvider('getBaseNames')] public function testBaseName(string $expected, int $value, ImageSize $size, ImageExtension|string|null $ext = null): void { $result = UserNamer::getBaseName($value, $size, $ext); diff --git a/tests/Traits/ArrayTraitTest.php b/tests/Traits/ArrayTraitTest.php index c35c3a95f..c43d84f0c 100644 --- a/tests/Traits/ArrayTraitTest.php +++ b/tests/Traits/ArrayTraitTest.php @@ -14,6 +14,7 @@ use App\Traits\ArrayTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(ArrayTrait::class)] @@ -160,7 +161,7 @@ public static function getUniqueMergedValues(): \Generator yield [['value', 'value1'], ['value2'], ['value', 'value1', 'value2']]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getColumnValues')] + #[DataProvider('getColumnValues')] public function testColumn(array $values, array $expected): void { $actual = $this->getColumn($values, self::KEY); @@ -170,21 +171,21 @@ public function testColumn(array $values, array $expected): void /** * @psalm-param int<0,2> $mode */ - #[\PHPUnit\Framework\Attributes\DataProvider('getColumnFilterValues')] + #[DataProvider('getColumnFilterValues')] public function testColumnFilter(array $values, array $expected, ?callable $callback = null, int $mode = 0): void { $actual = $this->getColumnFilter($values, self::KEY, $callback, $mode); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getColumnMaxValues')] + #[DataProvider('getColumnMaxValues')] public function testColumnMax(array $values, float $expected, float $default = 0.0): void { $actual = $this->getColumnMax($values, self::KEY, $default); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getColumnSumValues')] + #[DataProvider('getColumnSumValues')] public function testColumnSum(array $values, float $expected, float $default = 0.0): void { $actual = $this->getColumnSum($values, self::KEY, $default); @@ -239,7 +240,7 @@ public function testSorted(): void /** * @psalm-param 0|1|2 $mode */ - #[\PHPUnit\Framework\Attributes\DataProvider('getUniqueFilteredValues')] + #[DataProvider('getUniqueFilteredValues')] public function testUniqueFiltered(array $values, array $expected, ?callable $callback = null, int $mode = 0): void { $actual = $this->getUniqueFiltered($values, $callback, $mode); @@ -248,7 +249,7 @@ public function testUniqueFiltered(array $values, array $expected, ?callable $ca self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getUniqueMergedValues')] + #[DataProvider('getUniqueMergedValues')] public function testUniqueMerged(array $first, array $second, array $expected): void { $actual = $this->getUniqueMerged($first, $second); diff --git a/tests/Traits/CacheKeyTraitTest.php b/tests/Traits/CacheKeyTraitTest.php index 1987f9767..43720db26 100644 --- a/tests/Traits/CacheKeyTraitTest.php +++ b/tests/Traits/CacheKeyTraitTest.php @@ -14,6 +14,7 @@ use App\Traits\CacheKeyTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Contracts\Cache\ItemInterface; @@ -47,7 +48,7 @@ public static function getCleanKeys(): \Generator } } - #[\PHPUnit\Framework\Attributes\DataProvider('getCleanKeys')] + #[DataProvider('getCleanKeys')] public function testCleanKey(string $key, string $expected): void { $actual = $this->cleanKey($key); diff --git a/tests/Traits/CheckSubClassTraitTest.php b/tests/Traits/CheckSubClassTraitTest.php index 0d4814018..e027f82f4 100644 --- a/tests/Traits/CheckSubClassTraitTest.php +++ b/tests/Traits/CheckSubClassTraitTest.php @@ -17,6 +17,7 @@ use App\Interfaces\EntityInterface; use App\Traits\CheckSubClassTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(CheckSubClassTrait::class)] @@ -41,7 +42,7 @@ public static function getSubClass(): \Iterator /** * @psalm-param class-string $target */ - #[\PHPUnit\Framework\Attributes\DataProvider('getSubClass')] + #[DataProvider('getSubClass')] public function testSubClass(string|object $source, string $target, bool $exception = false): void { if ($exception) { diff --git a/tests/Traits/ImageSizeTraitTest.php b/tests/Traits/ImageSizeTraitTest.php index cd77db549..6eb8a167c 100644 --- a/tests/Traits/ImageSizeTraitTest.php +++ b/tests/Traits/ImageSizeTraitTest.php @@ -14,6 +14,7 @@ use App\Traits\ImageSizeTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(ImageSizeTrait::class)] @@ -28,7 +29,7 @@ public static function getSizes(): \Iterator yield [__DIR__ . '/../Data/images/example.jpg', [500, 477]]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getSizes')] + #[DataProvider('getSizes')] public function testSize(string $filename, array $expected): void { $actual = $this->getImageSize($filename); diff --git a/tests/Traits/MathTraitTest.php b/tests/Traits/MathTraitTest.php index c96d683d5..53e8311f6 100644 --- a/tests/Traits/MathTraitTest.php +++ b/tests/Traits/MathTraitTest.php @@ -14,6 +14,7 @@ use App\Traits\MathTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(MathTrait::class)] @@ -98,49 +99,49 @@ public static function getValidateIntRange(): \Iterator yield [101, 0, 100, 100]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsBitSet')] + #[DataProvider('getIsBitSet')] public function testIsBitSet(int $value, int $mask, bool $expected = true): void { $actual = $this->isBitSet($value, $mask); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsFloatEquals')] + #[DataProvider('getIsFloatEquals')] public function testIsFloatEquals(float $val1, float $val2, int $precision = 2, bool $expected = true): void { $actual = $this->isFloatEquals($val1, $val2, $precision); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsFloatZero')] + #[DataProvider('getIsFloatZero')] public function testIsFloatZero(float $val, int $precision = 2, bool $expected = true): void { $actual = $this->isFloatZero($val, $precision); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRound')] + #[DataProvider('getRound')] public function testRound(float $val, float $expected, int $precision = 2): void { $actual = $this->round($val, $precision); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getSafeDivide')] + #[DataProvider('getSafeDivide')] public function testSafeDivide(float $dividend, float $divisor, float $expected, float $default = 0.0): void { $actual = $this->safeDivide($dividend, $divisor, $default); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValidateFloatRange')] + #[DataProvider('getValidateFloatRange')] public function testValidateFloatRange(float $value, float $min, float $max, float $expected): void { $actual = $this->validateRange($value, $min, $max); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValidateIntRange')] + #[DataProvider('getValidateIntRange')] public function testValidateIntRange(int $value, int $min, int $max, int $expected): void { $actual = $this->validateRange($value, $min, $max); diff --git a/tests/Traits/RightsTraitTest.php b/tests/Traits/RightsTraitTest.php index 8286d4dd9..f0836a5b1 100644 --- a/tests/Traits/RightsTraitTest.php +++ b/tests/Traits/RightsTraitTest.php @@ -17,6 +17,7 @@ use App\Traits\RightsTrait; use Elao\Enum\FlagBag; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(RightsTrait::class)] @@ -37,25 +38,25 @@ public static function getRightsFields(): \Generator } } - #[\PHPUnit\Framework\Attributes\DataProvider('getRightsFields')] + #[DataProvider('getRightsFields')] public function testGetAdd(string $field): void { $this->checkAttribute($field, 'ADD'); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRightsFields')] + #[DataProvider('getRightsFields')] public function testGetDelete(string $field): void { $this->checkAttribute($field, 'DELETE'); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRightsFields')] + #[DataProvider('getRightsFields')] public function testGetEdit(string $field): void { $this->checkAttribute($field, 'EDIT'); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRightsFields')] + #[DataProvider('getRightsFields')] public function testGetEmpty(string $field): void { $permission = $this->__get($field); diff --git a/tests/Traits/RoleTranslatorTraitTest.php b/tests/Traits/RoleTranslatorTraitTest.php index 470e0193d..c5c313170 100644 --- a/tests/Traits/RoleTranslatorTraitTest.php +++ b/tests/Traits/RoleTranslatorTraitTest.php @@ -17,6 +17,7 @@ use App\Tests\TranslatorMockTrait; use App\Traits\RoleTranslatorTrait; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Symfony\Contracts\Translation\TranslatorInterface; @@ -59,7 +60,7 @@ public function getTranslator(): TranslatorInterface return $this->translator; } - #[\PHPUnit\Framework\Attributes\DataProvider('getRoleIcons')] + #[DataProvider('getRoleIcons')] public function testRoleIcon(RoleInterface|string $role, string $expected): void { $actual = $this->getRoleIcon($role); @@ -71,7 +72,7 @@ public function testRoleIcon(RoleInterface|string $role, string $expected): void * * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getTranslateRoles')] + #[DataProvider('getTranslateRoles')] public function testTranslateRole(RoleInterface|string $role, string $expected): void { $this->translator = $this->createTranslator($expected); diff --git a/tests/Traits/StrengthLevelTranslatorTraitTest.php b/tests/Traits/StrengthLevelTranslatorTraitTest.php index 5c6b5a4cc..ef574a060 100644 --- a/tests/Traits/StrengthLevelTranslatorTraitTest.php +++ b/tests/Traits/StrengthLevelTranslatorTraitTest.php @@ -17,6 +17,7 @@ use App\Traits\StrengthLevelTranslatorTrait; use App\Validator\Strength; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Context\ExecutionContext; @@ -89,7 +90,7 @@ public function testTranslateInvalidLevel(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getTranslateLevels')] + #[DataProvider('getTranslateLevels')] public function testTranslateLevel(int $value, string $message): void { $expected = "strength_level.$message"; diff --git a/tests/Twig/ConstantExtensionTest.php b/tests/Twig/ConstantExtensionTest.php index dbf425455..da8139ea0 100644 --- a/tests/Twig/ConstantExtensionTest.php +++ b/tests/Twig/ConstantExtensionTest.php @@ -15,6 +15,7 @@ use App\Tests\KernelServiceTestCase; use App\Twig\ConstantExtension; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Cache\InvalidArgumentException; #[CoversClass(ConstantExtension::class)] @@ -62,7 +63,7 @@ public static function getEntityVoterConstants(): \Iterator /** * @throws InvalidArgumentException */ - #[\PHPUnit\Framework\Attributes\DataProvider('getCalculationServiceConstants')] + #[DataProvider('getCalculationServiceConstants')] public function testCalculationService(string $key, int $value): void { $globals = $this->extension->getGlobals(); @@ -74,7 +75,7 @@ public function testCalculationService(string $key, int $value): void /** * @throws InvalidArgumentException */ - #[\PHPUnit\Framework\Attributes\DataProvider('getEntityVoterConstants')] + #[DataProvider('getEntityVoterConstants')] public function testEntityVoter(string $key, string $value): void { $globals = $this->extension->getGlobals(); diff --git a/tests/Types/FixedFloatTypeTest.php b/tests/Types/FixedFloatTypeTest.php index 03a449983..6ae24a2fc 100644 --- a/tests/Types/FixedFloatTypeTest.php +++ b/tests/Types/FixedFloatTypeTest.php @@ -16,6 +16,7 @@ use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Types\ConversionException; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(FixedFloatType::class)] @@ -37,7 +38,7 @@ public static function getValues(): \Generator * * @psalm-suppress InternalMethod */ - #[\PHPUnit\Framework\Attributes\DataProvider('getValues')] + #[DataProvider('getValues')] public function testConvertToPHPValue(mixed $value, float $expected): void { $platform = new MySQLPlatform(); diff --git a/tests/Utils/DateUtilsTest.php b/tests/Utils/DateUtilsTest.php index e0ac95247..3c4667e24 100644 --- a/tests/Utils/DateUtilsTest.php +++ b/tests/Utils/DateUtilsTest.php @@ -15,6 +15,7 @@ use App\Utils\DateUtils; use App\Utils\FormatUtils; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(DateUtils::class)] @@ -210,49 +211,49 @@ public function testAddByString(): void self::assertSame('2020-01-17', $add->format('Y-m-d')); } - #[\PHPUnit\Framework\Attributes\DataProvider('getCompletYears')] + #[DataProvider('getCompletYears')] public function testCompletYear(int $value, int $expected, int $change = 1930): void { $year = DateUtils::completYear($value, $change); self::assertSame($expected, $year); } - #[\PHPUnit\Framework\Attributes\DataProvider('getFormatFormDate')] + #[DataProvider('getFormatFormDate')] public function testFormatFormDate(?\DateTimeInterface $date, ?string $expected): void { $actual = DateUtils::formatFormDate($date); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getDays')] + #[DataProvider('getDays')] public function testGetDay(\DateTimeInterface $date, int $expected): void { $actual = DateUtils::getDay($date); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getMonths')] + #[DataProvider('getMonths')] public function testGetMonth(\DateTimeInterface $date, int $expected): void { $actual = DateUtils::getMonth($date); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getWeeks')] + #[DataProvider('getWeeks')] public function testGetWeek(\DateTimeInterface $date, int $expected): void { $actual = DateUtils::getWeek($date); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getYears')] + #[DataProvider('getYears')] public function testGetYear(\DateTimeInterface $date, int $expected): void { $actual = DateUtils::getYear($date); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getMonthNames')] + #[DataProvider('getMonthNames')] public function testMonthNames(string $name, int $index): void { $values = DateUtils::getMonths(); @@ -266,14 +267,14 @@ public function testMonthsCount(): void self::assertCount(12, $values); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRemoveTimes')] + #[DataProvider('getRemoveTimes')] public function testRemoveTime(\DateTime|\DateTimeImmutable $date, \DateTimeInterface $expected): void { $value = DateUtils::removeTime($date); self::assertSame($expected->getTimestamp(), $value->getTimestamp()); } - #[\PHPUnit\Framework\Attributes\DataProvider('getShortMonthNames')] + #[DataProvider('getShortMonthNames')] public function testShortMonthNames(string $name, int $index): void { $values = DateUtils::getShortMonths(); @@ -287,7 +288,7 @@ public function testShortMonthsCount(): void self::assertCount(12, $values); } - #[\PHPUnit\Framework\Attributes\DataProvider('getShortWeekdayNames')] + #[DataProvider('getShortWeekdayNames')] public function testShortWeekdayNames(string $name, int $index, string $firstDay = 'sunday'): void { $values = DateUtils::getShortWeekdays($firstDay); @@ -322,7 +323,7 @@ public function testSubByString(): void self::assertSame('2020-01-03', $add->format('Y-m-d')); } - #[\PHPUnit\Framework\Attributes\DataProvider('getWeekdayNames')] + #[DataProvider('getWeekdayNames')] public function testWeekdayNames(string $name, int $index, string $firstDay = 'sunday'): void { $values = DateUtils::getWeekdays($firstDay); diff --git a/tests/Utils/FileUtilsTest.php b/tests/Utils/FileUtilsTest.php index b1aaa51b3..c8ed600e8 100644 --- a/tests/Utils/FileUtilsTest.php +++ b/tests/Utils/FileUtilsTest.php @@ -15,6 +15,7 @@ use App\Enums\ImageExtension; use App\Utils\FileUtils; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(FileUtils::class)] @@ -83,7 +84,7 @@ public static function getRealPath(): \Iterator yield [new \SplFileInfo(__FILE__), __FILE__]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getBuildPaths')] + #[DataProvider('getBuildPaths')] public function testBuildPath(string $expected, string ...$segments): void { $actual = FileUtils::buildPath(...$segments); @@ -124,14 +125,14 @@ public function testExist(): void self::assertTrue(FileUtils::exists(__FILE__)); } - #[\PHPUnit\Framework\Attributes\DataProvider('getFormatSize')] + #[DataProvider('getFormatSize')] public function testFormatSize(string|\SplFileInfo|int $path, string $expected): void { $actual = FileUtils::formatSize($path); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getExtension')] + #[DataProvider('getExtension')] public function testGetExtension(string $file, string $expected, bool $forceLowerCase = false): void { $actual = FileUtils::getExtension($file, $forceLowerCase); @@ -179,7 +180,7 @@ public function testNormalizeDirectory(): void self::assertSame('C:' . \DIRECTORY_SEPARATOR . 'Temp', $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getRealPath')] + #[DataProvider('getRealPath')] public function testRealPath(string|\SplFileInfo $file, string $expected): void { $actual = FileUtils::realPath($file); diff --git a/tests/Utils/FormatUtilsTest.php b/tests/Utils/FormatUtilsTest.php index 7da3007a3..2ff9357c1 100644 --- a/tests/Utils/FormatUtilsTest.php +++ b/tests/Utils/FormatUtilsTest.php @@ -15,6 +15,7 @@ use App\Model\LogFile; use App\Utils\FormatUtils; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(FormatUtils::class)] @@ -234,7 +235,7 @@ public static function getTimes(): \Iterator * @psalm-param int<-1,3>|null $dateType * @psalm-param int<-1,3>|null $timeType */ - #[\PHPUnit\Framework\Attributes\DataProvider('getDateFormatterPatterns')] + #[DataProvider('getDateFormatterPatterns')] public function testDateFormatterPattern( string $pattern, string $expected, @@ -260,7 +261,7 @@ public function testDefaultLocale(): void self::assertSame('fr_CH', FormatUtils::DEFAULT_LOCALE); } - #[\PHPUnit\Framework\Attributes\DataProvider('getAmounts')] + #[DataProvider('getAmounts')] public function testFormatAmount(string|int|float|null $number, string $expected): void { $actual = FormatUtils::formatAmount($number); @@ -270,7 +271,7 @@ public function testFormatAmount(string|int|float|null $number, string $expected /** * @psalm-param int<-1,3>|null $dateType */ - #[\PHPUnit\Framework\Attributes\DataProvider('getDates')] + #[DataProvider('getDates')] public function testFormatDate( \DateTimeInterface|int|null $date, ?string $expected, @@ -285,7 +286,7 @@ public function testFormatDate( * @psalm-param int<-1,3>|null $dateType * @psalm-param int<-1,3>|null $timeType */ - #[\PHPUnit\Framework\Attributes\DataProvider('getDateTimes')] + #[DataProvider('getDateTimes')] public function testFormatDateTime( \DateTimeInterface|int|null $date, ?string $expected, @@ -297,14 +298,14 @@ public function testFormatDateTime( self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIds')] + #[DataProvider('getIds')] public function testFormatId(int|float|string|null $number, string $expected): void { $actual = FormatUtils::formatId($number); self::assertSame($expected, $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIntegers')] + #[DataProvider('getIntegers')] public function testFormatInteger(\Countable|array|int|float|string|null $number, string $expected): void { $actual = FormatUtils::formatInt($number); @@ -314,7 +315,7 @@ public function testFormatInteger(\Countable|array|int|float|string|null $number /** * @psalm-param \NumberFormatter::ROUND_* $roundingMode */ - #[\PHPUnit\Framework\Attributes\DataProvider('getPercents')] + #[DataProvider('getPercents')] public function testFormatPercent( int|float|string|null $number, string $expected, @@ -335,7 +336,7 @@ public function testFormatPercent( /** * @psalm-param int<-1,3>|null $timeType */ - #[\PHPUnit\Framework\Attributes\DataProvider('getTimes')] + #[DataProvider('getTimes')] public function testFormatTime( \DateTimeInterface|int|null $date, ?string $expected, diff --git a/tests/Utils/StringUtilsTest.php b/tests/Utils/StringUtilsTest.php index 1daafb5cc..bc3924cc5 100644 --- a/tests/Utils/StringUtilsTest.php +++ b/tests/Utils/StringUtilsTest.php @@ -15,6 +15,7 @@ use App\Entity\Calculation; use App\Utils\StringUtils; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; #[CoversClass(StringUtils::class)] @@ -97,21 +98,21 @@ public static function getStartWith(): \Iterator yield ['fake', 'FA', true, true]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getAscii')] + #[DataProvider('getAscii')] public function testAscii(string $value, string $expected): void { $result = StringUtils::ascii($value); self::assertSame($expected, $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('getCapitalize')] + #[DataProvider('getCapitalize')] public function testCapitalize(string $value, string $expected): void { $result = StringUtils::capitalize($value); self::assertSame($expected, $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('getContains')] + #[DataProvider('getContains')] public function testContains(string $haystack, string $needle, bool $ignore_case, bool $expected): void { $result = StringUtils::contains($haystack, $needle, $ignore_case); @@ -166,21 +167,21 @@ public function testEncodeJsonWidthException(): void self::fail("An \InvalidArgumentException must be throw."); } - #[\PHPUnit\Framework\Attributes\DataProvider('getEndWith')] + #[DataProvider('getEndWith')] public function testEndWith(string $haystack, string $needle, bool $ignore_case, bool $expected): void { $result = StringUtils::endWith($haystack, $needle, $ignore_case); self::assertSame($expected, $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('getEqualIgnoreCase')] + #[DataProvider('getEqualIgnoreCase')] public function testEqualIgnoreCase(string $string1, string $string2, bool $expected = true): void { $result = StringUtils::equalIgnoreCase($string1, $string2); self::assertSame($result, $expected); } - #[\PHPUnit\Framework\Attributes\DataProvider('getExportVar')] + #[DataProvider('getExportVar')] public function testExportVar(mixed $var, mixed $expected): void { $result = StringUtils::exportVar($var); @@ -192,7 +193,7 @@ public function testExportVar(mixed $var, mixed $expected): void * * @psalm-suppress PossiblyNullArgument */ - #[\PHPUnit\Framework\Attributes\DataProvider('getShortName')] + #[DataProvider('getShortName')] public function testGetShortName(object|string|null $var, mixed $expected, bool $exception = false): void { if (null === $var) { @@ -204,7 +205,7 @@ public function testGetShortName(object|string|null $var, mixed $expected, bool self::assertSame($expected, $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('getIsString')] + #[DataProvider('getIsString')] public function testIsString(?string $var, bool $expected): void { $result = StringUtils::isString($var); @@ -222,7 +223,7 @@ public function testSlug(): void self::assertSame('Workspace-settings', $actual); } - #[\PHPUnit\Framework\Attributes\DataProvider('getStartWith')] + #[DataProvider('getStartWith')] public function testStartWith(string $haystack, string $needle, bool $ignore_case, bool $expected): void { $result = StringUtils::startWith($haystack, $needle, $ignore_case); diff --git a/tests/Validator/PasswordValidatorTest.php b/tests/Validator/PasswordValidatorTest.php index c342461b6..968fe8fbb 100644 --- a/tests/Validator/PasswordValidatorTest.php +++ b/tests/Validator/PasswordValidatorTest.php @@ -15,6 +15,7 @@ use App\Validator\Password; use App\Validator\PasswordValidator; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; /** @@ -66,7 +67,7 @@ public function testAll(): void self::assertNoViolation(); } - #[\PHPUnit\Framework\Attributes\DataProvider('getPasswords')] + #[DataProvider('getPasswords')] public function testCompromised(string $value, bool $violation): void { $options = ['compromised' => true]; @@ -84,7 +85,7 @@ public function testCompromised(string $value, bool $violation): void } } - #[\PHPUnit\Framework\Attributes\DataProvider('getConstraints')] + #[DataProvider('getConstraints')] public function testEmptyIsValid(string $constraint): void { $constraint = $this->createPassword([$constraint => true]); @@ -92,7 +93,7 @@ public function testEmptyIsValid(string $constraint): void self::assertNoViolation(); } - #[\PHPUnit\Framework\Attributes\DataProvider('getInvalidValues')] + #[DataProvider('getInvalidValues')] public function testInvalid(mixed $value, array $options, string $message, string $code, array $parameters = []): void { $constraint = $this->createPassword($options); @@ -104,7 +105,7 @@ public function testInvalid(mixed $value, array $options, string $message, strin ->assertRaised(); } - #[\PHPUnit\Framework\Attributes\DataProvider('getConstraints')] + #[DataProvider('getConstraints')] public function testNullIsValid(string $constraint): void { $constraint = $this->createPassword([$constraint => true]); @@ -112,7 +113,7 @@ public function testNullIsValid(string $constraint): void self::assertNoViolation(); } - #[\PHPUnit\Framework\Attributes\DataProvider('getValidValues')] + #[DataProvider('getValidValues')] public function testValid(mixed $value, array $options): void { $constraint = $this->createPassword($options); diff --git a/tests/Validator/RecaptchaValidatorTest.php b/tests/Validator/RecaptchaValidatorTest.php index 6d974647d..6b2957356 100644 --- a/tests/Validator/RecaptchaValidatorTest.php +++ b/tests/Validator/RecaptchaValidatorTest.php @@ -16,6 +16,7 @@ use App\Validator\Recaptcha; use App\Validator\RecaptchaValidator; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use ReCaptcha\Response; use Symfony\Component\HttpFoundation\Request; @@ -48,7 +49,7 @@ public function testEmptyIsValid(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\DataProvider('getErrorCodes')] + #[DataProvider('getErrorCodes')] public function testErrorCodeIsInvalid(string $code): void { $contraint = $this->createConstraint(); diff --git a/tests/Validator/StrengthValidatorTest.php b/tests/Validator/StrengthValidatorTest.php index 6500de528..d68d96d29 100644 --- a/tests/Validator/StrengthValidatorTest.php +++ b/tests/Validator/StrengthValidatorTest.php @@ -18,6 +18,7 @@ use App\Validator\StrengthValidator; use Createnl\ZxcvbnBundle\ZxcvbnFactoryInterface; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\Exception; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; @@ -63,7 +64,7 @@ public static function getStrengths(): \Generator } } - #[\PHPUnit\Framework\Attributes\DataProvider('getStrengthLevels')] + #[DataProvider('getStrengthLevels')] public function testEmptyIsValid(StrengthLevel $level): void { $constraint = new Strength($level); @@ -87,7 +88,7 @@ public function testInvalidPath(): void self::fail('No such property exception must be raised.'); } - #[\PHPUnit\Framework\Attributes\DataProvider('getStrengthLevels')] + #[DataProvider('getStrengthLevels')] public function testNullIsValid(StrengthLevel $level): void { $constraint = new Strength($level); @@ -112,7 +113,7 @@ public function testPaths(): void self::assertNoViolation(); } - #[\PHPUnit\Framework\Attributes\DataProvider('getStrengths')] + #[DataProvider('getStrengths')] public function testStrength(string $value, int $strength, bool $violation): void { $level = StrengthLevel::tryFrom($strength) ?? StrengthLevel::NONE; @@ -133,7 +134,7 @@ public function testStrength(string $value, int $strength, bool $violation): voi } } - #[\PHPUnit\Framework\Attributes\DataProvider('getStrengthInvalids')] + #[DataProvider('getStrengthInvalids')] public function testStrengthInvalid(int $strength): void { $this->expectException(ConstraintDefinitionException::class); diff --git a/tests/Web/DatabaseTest.php b/tests/Web/DatabaseTest.php index 23fabdf08..3d15b28ff 100644 --- a/tests/Web/DatabaseTest.php +++ b/tests/Web/DatabaseTest.php @@ -32,6 +32,7 @@ use App\Tests\DatabaseTrait; use App\Tests\KernelServiceTestCase; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(Database::class)] class DatabaseTest extends KernelServiceTestCase @@ -82,7 +83,7 @@ public static function getUsers(): \Iterator * * @param class-string $className */ - #[\PHPUnit\Framework\Attributes\DataProvider('getRepositories')] + #[DataProvider('getRepositories')] public function testRepository(string $className, int $expected): void { /** @@ -95,7 +96,7 @@ public function testRepository(string $className, int $expected): void self::assertCount($expected, $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('getTables')] + #[DataProvider('getTables')] public function testTable(string $tableName, int $expected): void { $database = self::$database; @@ -108,7 +109,7 @@ public function testTable(string $tableName, int $expected): void /** * @psalm-param RoleInterface::ROLE_* $role */ - #[\PHPUnit\Framework\Attributes\DataProvider('getUsers')] + #[DataProvider('getUsers')] public function testUser(string $username, string $role): void { $repository = $this->getService(UserRepository::class); diff --git a/tests/Web/RoutesTest.php b/tests/Web/RoutesTest.php index 2572ec31f..eedb5de80 100644 --- a/tests/Web/RoutesTest.php +++ b/tests/Web/RoutesTest.php @@ -12,6 +12,7 @@ namespace App\Tests\Web; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -27,7 +28,7 @@ public static function getRoutes(): \Iterator yield ['/not_exist', self::ROLE_USER, Response::HTTP_NOT_FOUND]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getRoutes')] + #[DataProvider('getRoutes')] public function testRoutes(string $url, string $username, int $expected = Response::HTTP_OK): void { $this->loginUsername($username); diff --git a/tests/Web/UsersTest.php b/tests/Web/UsersTest.php index 229ef929d..0e86d5fcd 100644 --- a/tests/Web/UsersTest.php +++ b/tests/Web/UsersTest.php @@ -12,6 +12,8 @@ namespace App\Tests\Web; +use PHPUnit\Framework\Attributes\DataProvider; + /** * Test class for user's roles. */ @@ -34,7 +36,7 @@ public static function getUserRole(): \Iterator yield [self::ROLE_SUPER_ADMIN]; } - #[\PHPUnit\Framework\Attributes\DataProvider('getUserExist')] + #[DataProvider('getUserExist')] public function testUserExist(string $username, bool $exist): void { $user = $this->loadUser($username, false); @@ -45,7 +47,7 @@ public function testUserExist(string $username, bool $exist): void } } - #[\PHPUnit\Framework\Attributes\DataProvider('getUserRole')] + #[DataProvider('getUserRole')] public function testUserRole(string $username): void { /** @psalm-var \App\Interfaces\RoleInterface::ROLE_* $role */