From dc480f755cde7aeee05289e3459b5a35af13ec65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 14 Jul 2025 00:32:06 +0200 Subject: [PATCH] Migrated phpunit annotations to attributes --- rector.php | 4 +++ tests/API/APIDocsAvailabilityTest.php | 5 ++- .../ApplicationAvailabilityFunctionalTest.php | 11 +++---- .../AbstractAdminControllerTest.php | 24 +++++++------- .../AttachmentTypeControllerTest.php | 7 ++--- .../AdminPages/CategoryControllerTest.php | 7 ++--- .../AdminPages/FootprintControllerTest.php | 7 ++--- .../AdminPages/LabelProfileControllerTest.php | 7 +++-- .../AdminPages/ManufacturerControllerTest.php | 7 ++--- .../MeasurementUnitControllerTest.php | 7 ++--- .../AdminPages/ProjectControllerTest.php | 7 ++--- .../StorelocationControllerTest.php | 7 ++--- .../AdminPages/SupplierControllerTest.php | 7 ++--- tests/Controller/RedirectControllerTest.php | 31 +++++++++---------- .../Filters/Constraints/FilterTraitTest.php | 5 ++- tests/DatatablesAvailabilityTest.php | 5 ++- tests/Doctrine/SQLiteRegexMiddlewareTest.php | 13 +++----- tests/Entity/Attachments/AttachmentTest.php | 31 ++++++------------- tests/Entity/Parameters/PartParameterTest.php | 17 ++++------ tests/Entity/UserSystem/UserTest.php | 10 +++--- .../Helpers/BBCodeToMarkdownConverterTest.php | 3 +- tests/Helpers/IPAnonymizerTest.php | 5 ++- .../StructuralElementDenormalizerTest.php | 5 ++- .../AttachmentPathResolverTest.php | 13 +++----- .../AttachmentURLGeneratorTest.php | 3 +- .../BuiltinAttachmentsFinderTest.php | 5 ++- .../Attachments/FileTypeFilterToolsTest.php | 12 +++---- .../ImportExportSystem/EntityImporterTest.php | 10 +++--- .../InfoProviderSystem/DTOs/FileDTOTest.php | 5 ++- .../DTOs/ParameterDTOTest.php | 5 +-- .../BarcodeScanner/BarcodeRedirectorTest.php | 8 ++--- .../BarcodeScanner/BarcodeScanHelperTest.php | 9 ++---- .../Barcodes/BarcodeContentGeneratorTest.php | 9 ++---- .../LabelSystem/LabelGeneratorTest.php | 5 ++- .../LabelSystem/LabelTextReplacerTest.php | 9 ++---- .../AbstractElementProviderTest.php | 5 ++- .../GlobalProvidersTest.php | 5 ++- .../NamedElementProviderTest.php | 5 ++- .../PartLotProviderTest.php | 5 ++- .../PlaceholderProviders/PartProviderTest.php | 10 +++--- .../TimestampableElementProviderTest.php | 5 ++- .../LabelSystem/SandboxedTwigFactoryTest.php | 9 ++---- tests/Services/Misc/FAIconGeneratorTest.php | 5 ++- tests/Services/Misc/RangeParserTest.php | 9 ++---- .../Parameters/ParameterExtractorTest.php | 5 ++- .../Services/Parts/PricedetailHelperTest.php | 5 ++- .../Services/Trees/TreeViewGeneratorTest.php | 5 ++- .../UserSystem/PermissionManagerTest.php | 5 ++- .../TFA/BackupCodeGeneratorTest.php | 9 ++---- tests/Twig/UserExtensionTest.php | 5 ++- 50 files changed, 171 insertions(+), 246 deletions(-) diff --git a/rector.php b/rector.php index d1e9edd5..52457515 100644 --- a/rector.php +++ b/rector.php @@ -30,6 +30,10 @@ return RectorConfig::configure() __DIR__ . '/tests', ]) + ->withSets([ + PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES, + ]) + ->withRules([ DeclareStrictTypesRector::class ]) diff --git a/tests/API/APIDocsAvailabilityTest.php b/tests/API/APIDocsAvailabilityTest.php index d2ed7fa4..b7caa873 100644 --- a/tests/API/APIDocsAvailabilityTest.php +++ b/tests/API/APIDocsAvailabilityTest.php @@ -23,15 +23,14 @@ declare(strict_types=1); namespace App\Tests\API; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\UserSystem\User; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class APIDocsAvailabilityTest extends WebTestCase { - /** - * @dataProvider urlProvider - */ + #[DataProvider('urlProvider')] public function testDocAvailabilityForLoggedInUser(string $url): void { self::ensureKernelShutdown(); diff --git a/tests/ApplicationAvailabilityFunctionalTest.php b/tests/ApplicationAvailabilityFunctionalTest.php index 519f0cd5..3f5a911e 100644 --- a/tests/ApplicationAvailabilityFunctionalTest.php +++ b/tests/ApplicationAvailabilityFunctionalTest.php @@ -22,20 +22,19 @@ declare(strict_types=1); namespace App\Tests; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\DataProvider; use Generator; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * This test just ensures that different pages are available (do not throw an exception). - * - * @group DB - * @group slow */ +#[Group('DB')] +#[Group('slow')] class ApplicationAvailabilityFunctionalTest extends WebTestCase { - /** - * @dataProvider urlProvider - */ + #[DataProvider('urlProvider')] public function testPageIsSuccessful(string $url): void { //We have localized routes diff --git a/tests/Controller/AdminPages/AbstractAdminControllerTest.php b/tests/Controller/AdminPages/AbstractAdminControllerTest.php index af3aefee..ec858e4e 100644 --- a/tests/Controller/AdminPages/AbstractAdminControllerTest.php +++ b/tests/Controller/AdminPages/AbstractAdminControllerTest.php @@ -22,13 +22,13 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Security\Core\Exception\AccessDeniedException; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] abstract class AbstractAdminControllerTest extends WebTestCase { protected static string $base_path = 'not_valid'; @@ -43,10 +43,10 @@ abstract class AbstractAdminControllerTest extends WebTestCase } /** - * @dataProvider readDataProvider - * @group slow * Tests if you can access the /new part which is used to list all entities. Checks if permissions are working */ + #[DataProvider('readDataProvider')] + #[Group('slow')] public function testListEntries(string $user, bool $read): void { static::ensureKernelShutdown(); @@ -72,10 +72,13 @@ abstract class AbstractAdminControllerTest extends WebTestCase } /** - * @dataProvider readDataProvider - * @group slow * Tests if it is possible to access a specific entity. Checks if permissions are working. + * @param string $user + * @param bool $read + * @return void */ + #[DataProvider('readDataProvider')] + #[Group('slow')] public function testReadEntity(string $user, bool $read): void { //Test read access @@ -106,10 +109,9 @@ abstract class AbstractAdminControllerTest extends WebTestCase /** * Tests if deleting an entity is working. - * - * @group slow - * @dataProvider deleteDataProvider */ + #[DataProvider('deleteDataProvider')] + #[Group('slow')] public function testDeleteEntity(string $user, bool $delete): void { //Test read access diff --git a/tests/Controller/AdminPages/AttachmentTypeControllerTest.php b/tests/Controller/AdminPages/AttachmentTypeControllerTest.php index b98650bf..0a5b0f6d 100644 --- a/tests/Controller/AdminPages/AttachmentTypeControllerTest.php +++ b/tests/Controller/AdminPages/AttachmentTypeControllerTest.php @@ -22,12 +22,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Attachments\AttachmentType; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class AttachmentTypeControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/attachment_type'; diff --git a/tests/Controller/AdminPages/CategoryControllerTest.php b/tests/Controller/AdminPages/CategoryControllerTest.php index aa325b31..81a251b9 100644 --- a/tests/Controller/AdminPages/CategoryControllerTest.php +++ b/tests/Controller/AdminPages/CategoryControllerTest.php @@ -22,12 +22,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Parts\Category; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class CategoryControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/category'; diff --git a/tests/Controller/AdminPages/FootprintControllerTest.php b/tests/Controller/AdminPages/FootprintControllerTest.php index 6381ecd6..64b4164e 100644 --- a/tests/Controller/AdminPages/FootprintControllerTest.php +++ b/tests/Controller/AdminPages/FootprintControllerTest.php @@ -22,12 +22,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Parts\Footprint; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class FootprintControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/footprint'; diff --git a/tests/Controller/AdminPages/LabelProfileControllerTest.php b/tests/Controller/AdminPages/LabelProfileControllerTest.php index b4ce79cc..02d294e5 100644 --- a/tests/Controller/AdminPages/LabelProfileControllerTest.php +++ b/tests/Controller/AdminPages/LabelProfileControllerTest.php @@ -41,6 +41,8 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use App\Entity\LabelSystem\LabelProfile; use Symfony\Component\Security\Core\Exception\AccessDeniedException; @@ -51,10 +53,9 @@ class LabelProfileControllerTest extends AbstractAdminControllerTest /** * Tests if deleting an entity is working. - * - * @group slow - * @dataProvider deleteDataProvider */ + #[DataProvider('deleteDataProvider')] + #[Group('slow')] public function testDeleteEntity(string $user, bool $delete): void { //Test read access diff --git a/tests/Controller/AdminPages/ManufacturerControllerTest.php b/tests/Controller/AdminPages/ManufacturerControllerTest.php index d454c604..577c19af 100644 --- a/tests/Controller/AdminPages/ManufacturerControllerTest.php +++ b/tests/Controller/AdminPages/ManufacturerControllerTest.php @@ -22,12 +22,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Parts\Manufacturer; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class ManufacturerControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/manufacturer'; diff --git a/tests/Controller/AdminPages/MeasurementUnitControllerTest.php b/tests/Controller/AdminPages/MeasurementUnitControllerTest.php index 83eec70b..4ebfad26 100644 --- a/tests/Controller/AdminPages/MeasurementUnitControllerTest.php +++ b/tests/Controller/AdminPages/MeasurementUnitControllerTest.php @@ -22,12 +22,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Parts\MeasurementUnit; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class MeasurementUnitControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/measurement_unit'; diff --git a/tests/Controller/AdminPages/ProjectControllerTest.php b/tests/Controller/AdminPages/ProjectControllerTest.php index c0f5c288..b0a353ae 100644 --- a/tests/Controller/AdminPages/ProjectControllerTest.php +++ b/tests/Controller/AdminPages/ProjectControllerTest.php @@ -23,12 +23,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\ProjectSystem\Project; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class ProjectControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/project'; diff --git a/tests/Controller/AdminPages/StorelocationControllerTest.php b/tests/Controller/AdminPages/StorelocationControllerTest.php index 65a9fe34..42e57bc5 100644 --- a/tests/Controller/AdminPages/StorelocationControllerTest.php +++ b/tests/Controller/AdminPages/StorelocationControllerTest.php @@ -22,12 +22,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Parts\StorageLocation; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class StorelocationControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/store_location'; diff --git a/tests/Controller/AdminPages/SupplierControllerTest.php b/tests/Controller/AdminPages/SupplierControllerTest.php index d98a7f69..3a147576 100644 --- a/tests/Controller/AdminPages/SupplierControllerTest.php +++ b/tests/Controller/AdminPages/SupplierControllerTest.php @@ -22,12 +22,11 @@ declare(strict_types=1); namespace App\Tests\Controller\AdminPages; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Parts\Supplier; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class SupplierControllerTest extends AbstractAdminControllerTest { protected static string $base_path = '/en/supplier'; diff --git a/tests/Controller/RedirectControllerTest.php b/tests/Controller/RedirectControllerTest.php index f62c05c3..af322c43 100644 --- a/tests/Controller/RedirectControllerTest.php +++ b/tests/Controller/RedirectControllerTest.php @@ -22,16 +22,17 @@ declare(strict_types=1); namespace App\Tests\Controller; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Depends; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use App\Entity\UserSystem\User; use App\Repository\UserRepository; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -/** - * @group slow - * @group DB - */ +#[Group('slow')] +#[Group('DB')] class RedirectControllerTest extends WebTestCase { protected EntityManagerInterface $em; @@ -64,10 +65,9 @@ class RedirectControllerTest extends WebTestCase /** * Test if a certain request to an url will be redirected. - * - * @dataProvider urlMatchDataProvider - * @group slow */ + #[DataProvider('urlMatchDataProvider')] + #[Group('slow')] public function testUrlMatch($url, $expect_redirect): void { //$client = static::createClient(); @@ -97,11 +97,10 @@ class RedirectControllerTest extends WebTestCase /** * Test if the user is redirected to the localized version of a page, based on his settings. - * - * @dataProvider urlAddLocaleDataProvider - * @group slow - * @depends testUrlMatch */ + #[Depends('testUrlMatch')] + #[DataProvider('urlAddLocaleDataProvider')] + #[Group('slow')] public function testAddLocale(?string $user_locale, string $input_path, string $redirect_path): void { //Redirect path is absolute @@ -121,10 +120,9 @@ class RedirectControllerTest extends WebTestCase /** * Test if the user is redirected to the localized version of a page, based on his settings. * We simulate the situation of a reverse proxy here, by adding a prefix to the path. - * - * @dataProvider urlAddLocaleDataProvider - * @group slow */ + #[DataProvider('urlAddLocaleDataProvider')] + #[Group('slow')] public function testAddLocaleReverseProxy(?string $user_locale, string $input_path, string $redirect_path): void { //Input path remains unchanged, as this is what the server receives from the proxy @@ -147,10 +145,9 @@ class RedirectControllerTest extends WebTestCase /** * Test if the user is redirected to the localized version of a page, based on his settings. * We simulate the situation of serving Part-DB in a subfolder here. - * - * @dataProvider urlAddLocaleDataProvider - * @group slow */ + #[DataProvider('urlAddLocaleDataProvider')] + #[Group('slow')] public function testAddLocaleSubfolder(?string $user_locale, string $input_path, string $redirect_path): void { //Prefix our path with the proxy prefix diff --git a/tests/DataTables/Filters/Constraints/FilterTraitTest.php b/tests/DataTables/Filters/Constraints/FilterTraitTest.php index 1e32fdd8..8d87071c 100644 --- a/tests/DataTables/Filters/Constraints/FilterTraitTest.php +++ b/tests/DataTables/Filters/Constraints/FilterTraitTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Tests\DataTables\Filters\Constraints; +use PHPUnit\Framework\Attributes\DataProvider; use App\DataTables\Filters\Constraints\FilterTrait; use PHPUnit\Framework\TestCase; @@ -48,9 +49,7 @@ class FilterTraitTest extends TestCase yield [true, 'MAX(attachments.value)']; } - /** - * @dataProvider isAggregateFunctionStringDataProvider - */ + #[DataProvider('isAggregateFunctionStringDataProvider')] public function testIsAggregateFunctionString(bool $expected, string $input): void { $this->assertEquals($expected, $this->isAggregateFunctionString($input)); diff --git a/tests/DatatablesAvailabilityTest.php b/tests/DatatablesAvailabilityTest.php index 5af04627..9e4e7f15 100644 --- a/tests/DatatablesAvailabilityTest.php +++ b/tests/DatatablesAvailabilityTest.php @@ -41,13 +41,12 @@ declare(strict_types=1); namespace App\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class DatatablesAvailabilityTest extends WebTestCase { - /** - * @dataProvider urlProvider - */ + #[DataProvider('urlProvider')] public function testDataTable(string $url, ?array $ordering = null): void { //We have localized routes diff --git a/tests/Doctrine/SQLiteRegexMiddlewareTest.php b/tests/Doctrine/SQLiteRegexMiddlewareTest.php index 01abb16e..6278cc54 100644 --- a/tests/Doctrine/SQLiteRegexMiddlewareTest.php +++ b/tests/Doctrine/SQLiteRegexMiddlewareTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Tests\Doctrine; +use PHPUnit\Framework\Attributes\DataProvider; use App\Doctrine\Middleware\SQLiteRegexExtensionMiddlewareDriver; use PHPUnit\Framework\TestCase; @@ -41,9 +42,7 @@ class SQLiteRegexMiddlewareTest extends TestCase yield [1, '^a\d+$', 'a123']; } - /** - * @dataProvider regexpDataProvider - */ + #[DataProvider('regexpDataProvider')] public function testRegexp(int $expected, string $pattern, string $value): void { $this->assertSame($expected, SQLiteRegexExtensionMiddlewareDriver::regexp($pattern, $value)); @@ -73,17 +72,13 @@ class SQLiteRegexMiddlewareTest extends TestCase yield [6, 'c', ['b', 'a', 'b', 'a', 'b', 'c']]; } - /** - * @dataProvider fieldDataProvider - */ + #[DataProvider('fieldDataProvider')] public function testField(int $expected, string|int|null $value, array $array): void { $this->assertSame($expected, SQLiteRegexExtensionMiddlewareDriver::field($value, ...$array)); } - /** - * @dataProvider fieldDataProvider - */ + #[DataProvider('fieldDataProvider')] public function testField2(int $expected, string|int|null $value, array $array): void { //Should be the same as field, but with the array comma imploded diff --git a/tests/Entity/Attachments/AttachmentTest.php b/tests/Entity/Attachments/AttachmentTest.php index bac28fd4..c019c4bf 100644 --- a/tests/Entity/Attachments/AttachmentTest.php +++ b/tests/Entity/Attachments/AttachmentTest.php @@ -22,6 +22,8 @@ declare(strict_types=1); namespace App\Tests\Entity\Attachments; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Depends; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentTypeAttachment; @@ -89,9 +91,7 @@ class AttachmentTest extends TestCase yield [UserAttachment::class, User::class]; } - /** - * @dataProvider subClassesDataProvider - */ + #[DataProvider('subClassesDataProvider')] public function testSetElement(string $attachment_class, string $allowed_class): void { /** @var Attachment $attachment */ @@ -106,10 +106,9 @@ class AttachmentTest extends TestCase /** * Test that all attachment subclasses like PartAttachment or similar returns an exception, when a not allowed * element is passed. - * - * @dataProvider subClassesDataProvider - * @depends testSetElement */ + #[Depends('testSetElement')] + #[DataProvider('subClassesDataProvider')] public function testSetElementExceptionOnSubClasses(string $attachment_class, string $allowed_class): void { $this->expectException(InvalidArgumentException::class); @@ -135,9 +134,7 @@ class AttachmentTest extends TestCase yield [null, 'test.txt', null, null]; } - /** - * @dataProvider extensionDataProvider - */ + #[DataProvider('extensionDataProvider')] public function testGetExtension(?string $internal_path, ?string $external_path, ?string $originalFilename, ?string $expected): void { $attachment = new PartAttachment(); @@ -162,9 +159,7 @@ class AttachmentTest extends TestCase yield ['%SECURE%/foo.txt/test', 'https://test.de/picture.jpeg', false]; } - /** - * @dataProvider pictureDataProvider - */ + #[DataProvider('pictureDataProvider')] public function testIsPicture(?string $internal_path, ?string $external_path, bool $expected): void { $attachment = new PartAttachment(); @@ -184,9 +179,7 @@ class AttachmentTest extends TestCase yield ['%FOOTPRINTS%/foo/bar.txt', true]; } - /** - * @dataProvider builtinDataProvider - */ + #[DataProvider('builtinDataProvider')] public function testIsBuiltIn(?string $path, $expected): void { $attachment = new PartAttachment(); @@ -201,9 +194,7 @@ class AttachmentTest extends TestCase yield ['https://foo.bar/test?txt=test', 'foo.bar']; } - /** - * @dataProvider hostDataProvider - */ + #[DataProvider('hostDataProvider')] public function testGetHost(?string $path, ?string $expected): void { $attachment = new PartAttachment(); @@ -219,9 +210,7 @@ class AttachmentTest extends TestCase yield [null, 'https://www.google.de/test.txt', null, null]; } - /** - * @dataProvider filenameProvider - */ + #[DataProvider('filenameProvider')] public function testGetFilename(?string $internal_path, ?string $external_path, ?string $original_filename, ?string $expected): void { $attachment = new PartAttachment(); diff --git a/tests/Entity/Parameters/PartParameterTest.php b/tests/Entity/Parameters/PartParameterTest.php index 0e426d52..aec471cb 100644 --- a/tests/Entity/Parameters/PartParameterTest.php +++ b/tests/Entity/Parameters/PartParameterTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Entity\Parameters; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parameters\PartParameter; use PHPUnit\Framework\TestCase; @@ -80,9 +81,7 @@ class PartParameterTest extends TestCase yield ['10.23 $\mathrm{V}$ (9 $\mathrm{V}$ ... 11 $\mathrm{V}$) [Test]', 9, 10.23, 11, 'V', 'Test']; } - /** - * @dataProvider valueWithUnitDataProvider - */ + #[DataProvider('valueWithUnitDataProvider')] public function testGetValueMinWithUnit(string $expected, float $value, string $unit): void { $param = new PartParameter(); @@ -91,9 +90,7 @@ class PartParameterTest extends TestCase $this->assertSame($expected, $param->getValueMinWithUnit()); } - /** - * @dataProvider valueWithUnitDataProvider - */ + #[DataProvider('valueWithUnitDataProvider')] public function testGetValueMaxWithUnit(string $expected, float $value, string $unit): void { $param = new PartParameter(); @@ -102,9 +99,7 @@ class PartParameterTest extends TestCase $this->assertSame($expected, $param->getValueMaxWithUnit()); } - /** - * @dataProvider valueWithUnitDataProvider - */ + #[DataProvider('valueWithUnitDataProvider')] public function testGetValueTypicalWithUnit(string $expected, float $value, string $unit): void { $param = new PartParameter(); @@ -114,12 +109,12 @@ class PartParameterTest extends TestCase } /** - * @dataProvider formattedValueDataProvider * * @param float $min * @param float $typical * @param float $max */ + #[DataProvider('formattedValueDataProvider')] public function testGetFormattedValue(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void { $param = new PartParameter(); @@ -132,12 +127,12 @@ class PartParameterTest extends TestCase } /** - * @dataProvider formattedValueWithLatexDataProvider * * @param float $min * @param float $typical * @param float $max */ + #[DataProvider('formattedValueWithLatexDataProvider')] public function testGetFormattedValueWithLatex(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void { $param = new PartParameter(); diff --git a/tests/Entity/UserSystem/UserTest.php b/tests/Entity/UserSystem/UserTest.php index f11eec0f..bc4dec2d 100644 --- a/tests/Entity/UserSystem/UserTest.php +++ b/tests/Entity/UserSystem/UserTest.php @@ -22,6 +22,8 @@ declare(strict_types=1); namespace App\Tests\Entity\UserSystem; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use App\Entity\UserSystem\User; use App\Entity\UserSystem\WebauthnKey; use Doctrine\Common\Collections\Collection; @@ -52,9 +54,7 @@ class UserTest extends TestCase yield ['SSSk38498', true]; } - /** - * @dataProvider googleAuthenticatorEnabledDataProvider - */ + #[DataProvider('googleAuthenticatorEnabledDataProvider')] public function testIsGoogleAuthenticatorEnabled(?string $secret, bool $expected): void { $user = new User(); @@ -62,9 +62,7 @@ class UserTest extends TestCase $this->assertSame($expected, $user->isGoogleAuthenticatorEnabled()); } - /** - * @requires PHPUnit 8 - */ + #[RequiresPhpunit('8')] public function testSetBackupCodes(): void { $user = new User(); diff --git a/tests/Helpers/BBCodeToMarkdownConverterTest.php b/tests/Helpers/BBCodeToMarkdownConverterTest.php index 093ff98f..ad29f959 100644 --- a/tests/Helpers/BBCodeToMarkdownConverterTest.php +++ b/tests/Helpers/BBCodeToMarkdownConverterTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Helpers; +use PHPUnit\Framework\Attributes\DataProvider; use App\Helpers\BBCodeToMarkdownConverter; use PHPUnit\Framework\TestCase; @@ -46,11 +47,11 @@ class BBCodeToMarkdownConverterTest extends TestCase } /** - * @dataProvider dataProvider * * @param $bbcode * @param $expected */ + #[DataProvider('dataProvider')] public function testConvert($bbcode, $expected): void { $this->assertSame($expected, $this->converter->convert($bbcode)); diff --git a/tests/Helpers/IPAnonymizerTest.php b/tests/Helpers/IPAnonymizerTest.php index 66439e90..24994c49 100644 --- a/tests/Helpers/IPAnonymizerTest.php +++ b/tests/Helpers/IPAnonymizerTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Tests\Helpers; +use PHPUnit\Framework\Attributes\DataProvider; use App\Helpers\IPAnonymizer; use PHPUnit\Framework\TestCase; @@ -36,9 +37,7 @@ class IPAnonymizerTest extends TestCase yield ['fe80::', 'fe80::1fc4:15d8:78db:2319%enp4s0']; } - /** - * @dataProvider anonymizeDataProvider - */ + #[DataProvider('anonymizeDataProvider')] public function testAnonymize(string $expected, string $input): void { $this->assertSame($expected, IPAnonymizer::anonymize($input)); diff --git a/tests/Serializer/StructuralElementDenormalizerTest.php b/tests/Serializer/StructuralElementDenormalizerTest.php index 2543c4f3..31c9f0bb 100644 --- a/tests/Serializer/StructuralElementDenormalizerTest.php +++ b/tests/Serializer/StructuralElementDenormalizerTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Tests\Serializer; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Parts\Category; use App\Serializer\StructuralElementDenormalizer; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -53,9 +54,7 @@ class StructuralElementDenormalizerTest extends WebTestCase $this->assertTrue($this->service->supportsDenormalization(['name' => 'Test'], Category::class, 'json', ['groups' => ['import'], 'partdb_import' => true])); } - /** - * @group DB - */ + #[Group('DB')] public function testDenormalize(): void { //Check that we retrieve DB elements via the name diff --git a/tests/Services/Attachments/AttachmentPathResolverTest.php b/tests/Services/Attachments/AttachmentPathResolverTest.php index 3c432f48..b304e645 100644 --- a/tests/Services/Attachments/AttachmentPathResolverTest.php +++ b/tests/Services/Attachments/AttachmentPathResolverTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\Attachments; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Formatters\AmountFormatter; use App\Services\Attachments\AttachmentPathResolver; use const DIRECTORY_SEPARATOR; @@ -119,17 +120,13 @@ class AttachmentPathResolverTest extends WebTestCase yield ['/not/root'.$this->footprint_path, null]; } - /** - * @dataProvider placeholderDataProvider - */ + #[DataProvider('placeholderDataProvider')] public function testPlaceholderToRealPath($param, $expected): void { $this->assertSame($expected, $this->service->placeholderToRealPath($param)); } - /** - * @dataProvider realPathDataProvider - */ + #[DataProvider('realPathDataProvider')] public function testRealPathToPlaceholder($param, $expected, $old_method = false): void { $this->assertSame($expected, $this->service->realPathToPlaceholder($param, $old_method)); @@ -154,9 +151,7 @@ class AttachmentPathResolverTest extends WebTestCase yield [$this->footprint_path . '/Passive/Capacitors/CAPACITOR_CTS_A_15MM.png', '%FOOTPRINTS%/Passive/Capacitors/CAPACITOR_CTS_A_15MM.png']; } - /** - * @dataProvider germanFootprintPathdDataProvider - */ + #[DataProvider('germanFootprintPathdDataProvider')] public function testConversionOfGermanFootprintPaths(string $expected, string $input): void { $this->assertSame($expected, $this->service->placeholderToRealPath($input)); diff --git a/tests/Services/Attachments/AttachmentURLGeneratorTest.php b/tests/Services/Attachments/AttachmentURLGeneratorTest.php index 0db57f29..7816f697 100644 --- a/tests/Services/Attachments/AttachmentURLGeneratorTest.php +++ b/tests/Services/Attachments/AttachmentURLGeneratorTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\Attachments; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Attachments\AttachmentURLGenerator; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -48,11 +49,11 @@ class AttachmentURLGeneratorTest extends WebTestCase } /** - * @dataProvider dataProvider * * @param $input * @param $expected */ + #[DataProvider('dataProvider')] public function testTestabsolutePathToAssetPath($input, $expected): void { $this->assertSame($expected, static::$service->absolutePathToAssetPath($input, static::PUBLIC_DIR)); diff --git a/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php b/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php index 5ca656e3..569d84f9 100644 --- a/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php +++ b/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\Attachments; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Attachments\BuiltinAttachmentsFinder; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -54,9 +55,7 @@ class BuiltinAttachmentsFinderTest extends WebTestCase yield ['.txt', [], ['%FOOTPRINTS_3D%/hallo.txt']]; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testFind($keyword, $options, $expected): void { $value = static::$service->find($keyword, $options, static::$mock_list); diff --git a/tests/Services/Attachments/FileTypeFilterToolsTest.php b/tests/Services/Attachments/FileTypeFilterToolsTest.php index a6032a4b..73002371 100644 --- a/tests/Services/Attachments/FileTypeFilterToolsTest.php +++ b/tests/Services/Attachments/FileTypeFilterToolsTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\Attachments; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Attachments\FileTypeFilterTools; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -85,25 +86,20 @@ class FileTypeFilterToolsTest extends WebTestCase /** * Test the validateFilterString method. - * - * @dataProvider validateDataProvider */ + #[DataProvider('validateDataProvider')] public function testValidateFilterString(string $filter, bool $expected): void { $this->assertSame($expected, self::$service->validateFilterString($filter)); } - /** - * @dataProvider normalizeDataProvider - */ + #[DataProvider('normalizeDataProvider')] public function testNormalizeFilterString(string $filter, string $expected): void { $this->assertSame($expected, self::$service->normalizeFilterString($filter)); } - /** - * @dataProvider extensionAllowedDataProvider - */ + #[DataProvider('extensionAllowedDataProvider')] public function testIsExtensionAllowed(string $filter, string $extension, bool $expected): void { $this->assertSame($expected, self::$service->isExtensionAllowed($filter, $extension)); diff --git a/tests/Services/ImportExportSystem/EntityImporterTest.php b/tests/Services/ImportExportSystem/EntityImporterTest.php index 31859b6a..8f7d1004 100644 --- a/tests/Services/ImportExportSystem/EntityImporterTest.php +++ b/tests/Services/ImportExportSystem/EntityImporterTest.php @@ -22,6 +22,8 @@ declare(strict_types=1); namespace App\Tests\Services\ImportExportSystem; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Attachments\AttachmentType; use App\Entity\LabelSystem\LabelProfile; @@ -35,9 +37,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationListInterface; -/** - * @group DB - */ +#[Group('DB')] class EntityImporterTest extends WebTestCase { /** @@ -184,9 +184,7 @@ EOT; yield ['yaml', 'YAML']; } - /** - * @dataProvider formatDataProvider - */ + #[DataProvider('formatDataProvider')] public function testDetermineFormat(string $expected, string $extension): void { $this->assertSame($expected, $this->service->determineFormat($extension)); diff --git a/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php index f6e145f9..10312aca 100644 --- a/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Tests\Services\InfoProviderSystem\DTOs; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\InfoProviderSystem\DTOs\FileDTO; use PHPUnit\Framework\TestCase; @@ -40,9 +41,7 @@ class FileDTOTest extends TestCase yield ["test%7Cse", "test|se"]; } - /** - * @dataProvider escapingDataProvider - */ + #[DataProvider('escapingDataProvider')] public function testURLEscaping(string $expected, string $input): void { $fileDTO = new FileDTO( $input); diff --git a/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php index ee4ca39a..4bc9f5c6 100644 --- a/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Tests\Services\InfoProviderSystem\DTOs; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\InfoProviderSystem\DTOs\ParameterDTO; use PHPUnit\Framework\TestCase; @@ -234,18 +235,18 @@ class ParameterDTOTest extends TestCase } /** - * @dataProvider parseValueFieldDataProvider * @return void */ + #[DataProvider('parseValueFieldDataProvider')] public function testParseValueField(ParameterDTO $expected, string $name, string|float $value, ?string $unit = null, ?string $symbol = null, ?string $group = null) { $this->assertEquals($expected, ParameterDTO::parseValueField($name, $value, $unit, $symbol, $group)); } /** - * @dataProvider parseValueIncludingUnitDataProvider * @return void */ + #[DataProvider('parseValueIncludingUnitDataProvider')] public function testParseValueIncludingUnit(ParameterDTO $expected, string $name, string|float $value, ?string $symbol = null, ?string $group = null) { $this->assertEquals($expected, ParameterDTO::parseValueIncludingUnit($name, $value, $symbol, $group)); diff --git a/tests/Services/LabelSystem/BarcodeScanner/BarcodeRedirectorTest.php b/tests/Services/LabelSystem/BarcodeScanner/BarcodeRedirectorTest.php index 58030f93..c40e141d 100644 --- a/tests/Services/LabelSystem/BarcodeScanner/BarcodeRedirectorTest.php +++ b/tests/Services/LabelSystem/BarcodeScanner/BarcodeRedirectorTest.php @@ -41,6 +41,8 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\BarcodeScanner; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use App\Entity\LabelSystem\LabelSupportedElement; use App\Services\LabelSystem\BarcodeScanner\BarcodeRedirector; use App\Services\LabelSystem\BarcodeScanner\BarcodeSourceType; @@ -66,10 +68,8 @@ final class BarcodeRedirectorTest extends KernelTestCase yield [new LocalBarcodeScanResult(LabelSupportedElement::STORELOCATION, 1, BarcodeSourceType::INTERNAL), '/en/store_location/1/parts']; } - /** - * @dataProvider urlDataProvider - * @group DB - */ + #[DataProvider('urlDataProvider')] + #[Group('DB')] public function testGetRedirectURL(LocalBarcodeScanResult $scanResult, string $url): void { $this->assertSame($url, $this->service->getRedirectURL($scanResult)); diff --git a/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php b/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php index 74ae068a..fcea7730 100644 --- a/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php +++ b/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\BarcodeScanner; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\LabelSystem\LabelSupportedElement; use App\Services\LabelSystem\BarcodeScanner\BarcodeScanHelper; use App\Services\LabelSystem\BarcodeScanner\BarcodeScanResultInterface; @@ -140,17 +141,13 @@ class BarcodeScanHelperTest extends WebTestCase yield ['']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testNormalizeBarcodeContent(BarcodeScanResultInterface $expected, string $input): void { $this->assertEquals($expected, $this->service->scanBarcodeContent($input)); } - /** - * @dataProvider invalidDataProvider - */ + #[DataProvider('invalidDataProvider')] public function testInvalidFormats(string $input): void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php b/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php index 9d0ed7e2..ecaa8bf5 100644 --- a/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php +++ b/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\Barcodes; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Entity\Parts\StorageLocation; @@ -71,17 +72,13 @@ class BarcodeContentGeneratorTest extends KernelTestCase yield ['/scan/location/0', StorageLocation::class]; } - /** - * @dataProvider Barcode1DDataProvider - */ + #[DataProvider('Barcode1DDataProvider')] public function testGet1DBarcodeContent(string $expected, string $class): void { $this->assertSame($expected, $this->service->get1DBarcodeContent(new $class())); } - /** - * @dataProvider Barcode2DDataProvider - */ + #[DataProvider('Barcode2DDataProvider')] public function testGetURLContent(string $expected, string $class): void { $url = $this->service->getURLContent(new $class()); diff --git a/tests/Services/LabelSystem/LabelGeneratorTest.php b/tests/Services/LabelSystem/LabelGeneratorTest.php index 88ab97c5..916d4317 100644 --- a/tests/Services/LabelSystem/LabelGeneratorTest.php +++ b/tests/Services/LabelSystem/LabelGeneratorTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Base\AbstractDBElement; use App\Entity\LabelSystem\LabelOptions; use App\Entity\LabelSystem\LabelSupportedElement; @@ -70,9 +71,7 @@ class LabelGeneratorTest extends WebTestCase yield [LabelSupportedElement::STORELOCATION, StorageLocation::class]; } - /** - * @dataProvider supportsDataProvider - */ + #[DataProvider('supportsDataProvider')] public function testSupports(LabelSupportedElement $type, string $class): void { $options = new LabelOptions(); diff --git a/tests/Services/LabelSystem/LabelTextReplacerTest.php b/tests/Services/LabelSystem/LabelTextReplacerTest.php index e5c7c26e..4af74275 100644 --- a/tests/Services/LabelSystem/LabelTextReplacerTest.php +++ b/tests/Services/LabelSystem/LabelTextReplacerTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Services\LabelSystem\LabelTextReplacer; @@ -94,17 +95,13 @@ class LabelTextReplacerTest extends WebTestCase yield ['TEST[[ ]]TEST', 'TEST[[ ]]TEST']; } - /** - * @dataProvider handlePlaceholderDataProvider - */ + #[DataProvider('handlePlaceholderDataProvider')] public function testHandlePlaceholder(string $expected, string $input): void { $this->assertSame($expected, $this->service->handlePlaceholder($input, $this->target)); } - /** - * @dataProvider replaceDataProvider - */ + #[DataProvider('replaceDataProvider')] public function testReplace(string $expected, string $input): void { $this->assertSame($expected, $this->service->replace($input, $this->target)); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php index 3c40a9ac..4e902862 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\PlaceholderProviders; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Base\AbstractDBElement; use App\Services\LabelSystem\PlaceholderProviders\AbstractDBElementProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -68,9 +69,7 @@ class AbstractElementProviderTest extends WebTestCase yield ['123', '[[ID]]']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testReplace(string $expected, string $placeholder): void { $this->assertSame($expected, $this->service->replace($placeholder, $this->target)); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php b/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php index 854e7467..6f41e057 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\PlaceholderProviders; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parts\Part; use App\Services\LabelSystem\PlaceholderProviders\GlobalProviders; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -67,9 +68,7 @@ class GlobalProvidersTest extends WebTestCase yield ['anonymous', '[[USERNAME]]']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testReplace(string $expected, string $placeholder): void { $this->assertSame($expected, $this->service->replace($placeholder, $this->target)); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php index 7360b2d2..2e333c13 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\PlaceholderProviders; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Contracts\NamedElementInterface; use App\Services\LabelSystem\PlaceholderProviders\NamedElementProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -71,9 +72,7 @@ class NamedElementProviderTest extends WebTestCase yield ['This is my Name', '[[NAME]]']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testReplace(string $expected, string $placeholder): void { $this->assertSame($expected, $this->service->replace($placeholder, $this->target)); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php index 98285aa5..8826ddcf 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\PlaceholderProviders; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Entity\Parts\StorageLocation; @@ -101,9 +102,7 @@ class PartLotProviderTest extends WebTestCase yield ['user', '[[OWNER_USERNAME]]']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testReplace(string $expected, string $placeholder): void { $this->assertSame($expected, $this->service->replace($placeholder, $this->target)); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php index db3ebad1..01cad822 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php @@ -41,6 +41,8 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\PlaceholderProviders; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parts\ManufacturingStatus; use Doctrine\ORM\EntityManager; use App\Entity\Parts\Category; @@ -50,9 +52,7 @@ use App\Services\LabelSystem\PlaceholderProviders\PartProvider; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -/** - * @group DB - */ +#[Group('DB')] class PartProviderTest extends WebTestCase { /** @@ -105,9 +105,7 @@ class PartProviderTest extends WebTestCase yield ['Bold Italic', '[[COMMENT_T]]']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testReplace(string $expected, string $placeholder): void { $this->assertSame($expected, $this->service->replace($placeholder, $this->target)); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php index 07bb4270..8af988f7 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\PlaceholderProviders; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Contracts\TimeStampableInterface; use App\Services\LabelSystem\PlaceholderProviders\GlobalProviders; use App\Services\LabelSystem\PlaceholderProviders\TimestampableElementProvider; @@ -81,9 +82,7 @@ class TimestampableElementProviderTest extends WebTestCase yield ['1/1/00, 12:00 AM', '[[CREATION_DATE]]']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testReplace(string $expected, string $placeholder): void { $this->assertSame($expected, $this->service->replace($placeholder, $this->target)); diff --git a/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php b/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php index 495a2f45..26ba131e 100644 --- a/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php +++ b/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\LabelSystem\LabelOptions; use App\Entity\LabelSystem\LabelProcessMode; use App\Entity\LabelSystem\LabelSupportedElement; @@ -103,9 +104,7 @@ class SandboxedTwigFactoryTest extends WebTestCase yield ['{{ part.setCategory(null) }}']; } - /** - * @dataProvider twigDataProvider - */ + #[DataProvider('twigDataProvider')] public function testTwigFeatures(string $twig): void { $options = new LabelOptions(); @@ -123,9 +122,7 @@ class SandboxedTwigFactoryTest extends WebTestCase $this->assertIsString($str); } - /** - * @dataProvider twigNotAllowedDataProvider - */ + #[DataProvider('twigNotAllowedDataProvider')] public function testTwigForbidden(string $twig): void { $this->expectException(SecurityError::class); diff --git a/tests/Services/Misc/FAIconGeneratorTest.php b/tests/Services/Misc/FAIconGeneratorTest.php index 1bfc740c..f5c30b72 100644 --- a/tests/Services/Misc/FAIconGeneratorTest.php +++ b/tests/Services/Misc/FAIconGeneratorTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\Misc; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Misc\FAIconGenerator; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -95,9 +96,7 @@ class FAIconGeneratorTest extends WebTestCase yield ['fgd', 'fa-file']; } - /** - * @dataProvider fileExtensionDataProvider - */ + #[DataProvider('fileExtensionDataProvider')] public function testFileExtensionToFAType(string $ext, string $expected): void { $this->assertSame($expected, $this->service->fileExtensionToFAType($ext), 'Failed for extension .'.$ext); diff --git a/tests/Services/Misc/RangeParserTest.php b/tests/Services/Misc/RangeParserTest.php index 1a9b2146..71c412cb 100644 --- a/tests/Services/Misc/RangeParserTest.php +++ b/tests/Services/Misc/RangeParserTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\Misc; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Misc\RangeParser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -96,9 +97,7 @@ class RangeParserTest extends WebTestCase yield [false, '1, 2 test']; } - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testParse(array $expected, string $input, bool $must_throw = false): void { if ($must_throw) { @@ -109,9 +108,7 @@ class RangeParserTest extends WebTestCase } } - /** - * @dataProvider validDataProvider - */ + #[DataProvider('validDataProvider')] public function testIsValidRange(bool $expected, string $input): void { $this->assertSame($expected, $this->service->isValidRange($input)); diff --git a/tests/Services/Parameters/ParameterExtractorTest.php b/tests/Services/Parameters/ParameterExtractorTest.php index 148470d1..8c6e7df1 100644 --- a/tests/Services/Parameters/ParameterExtractorTest.php +++ b/tests/Services/Parameters/ParameterExtractorTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\Parameters; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parameters\AbstractParameter; use App\Services\Parameters\ParameterExtractor; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -69,9 +70,7 @@ class ParameterExtractorTest extends WebTestCase yield ['A [link](https://demo.part-db.de) should not be matched']; } - /** - * @dataProvider emptyDataProvider - */ + #[DataProvider('emptyDataProvider')] public function testShouldReturnEmpty(string $input): void { $this->assertEmpty($this->service->extractParameters($input)); diff --git a/tests/Services/Parts/PricedetailHelperTest.php b/tests/Services/Parts/PricedetailHelperTest.php index cfb4a043..b9c5e72b 100644 --- a/tests/Services/Parts/PricedetailHelperTest.php +++ b/tests/Services/Parts/PricedetailHelperTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\Parts; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parts\Part; use App\Entity\PriceInformations\Orderdetail; use App\Entity\PriceInformations\Pricedetail; @@ -81,9 +82,7 @@ class PricedetailHelperTest extends WebTestCase yield [$part, 10.0, 'Part with multiple orderdetails failed']; } - /** - * @dataProvider maxDiscountAmountDataProvider - */ + #[DataProvider('maxDiscountAmountDataProvider')] public function testGetMaxDiscountAmount(Part $part, ?float $expected_result, string $message): void { $this->assertSame($expected_result, $this->service->getMaxDiscountAmount($part), $message); diff --git a/tests/Services/Trees/TreeViewGeneratorTest.php b/tests/Services/Trees/TreeViewGeneratorTest.php index f34c855d..ebec94d6 100644 --- a/tests/Services/Trees/TreeViewGeneratorTest.php +++ b/tests/Services/Trees/TreeViewGeneratorTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\Trees; +use PHPUnit\Framework\Attributes\Group; use App\Entity\Attachments\AttachmentType; use App\Entity\Parts\Category; use App\Helpers\Trees\TreeViewNode; @@ -29,9 +30,7 @@ use App\Services\Trees\TreeViewGenerator; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -/** - * @group DB - */ +#[Group('DB')] class TreeViewGeneratorTest extends WebTestCase { protected $em; diff --git a/tests/Services/UserSystem/PermissionManagerTest.php b/tests/Services/UserSystem/PermissionManagerTest.php index cfe74ce7..3082e3d8 100644 --- a/tests/Services/UserSystem/PermissionManagerTest.php +++ b/tests/Services/UserSystem/PermissionManagerTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\UserSystem; +use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\UserSystem\Group; use App\Entity\UserSystem\PermissionData; use App\Entity\UserSystem\User; @@ -101,9 +102,7 @@ class PermissionManagerTest extends WebTestCase yield ['tools']; } - /** - * @dataProvider getPermissionNames - */ + #[DataProvider('getPermissionNames')] public function testListOperationsForPermission($perm_name): void { $arr = $this->service->listOperationsForPermission($perm_name); diff --git a/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php b/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php index b489eec2..83f39cae 100644 --- a/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php +++ b/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace App\Tests\Services\UserSystem\TFA; +use PHPUnit\Framework\Attributes\DataProvider; use App\Services\UserSystem\TFA\BackupCodeGenerator; use PHPUnit\Framework\TestCase; use RuntimeException; @@ -54,9 +55,7 @@ class BackupCodeGeneratorTest extends TestCase yield [16]; } - /** - * @dataProvider codeLengthDataProvider - */ + #[DataProvider('codeLengthDataProvider')] public function testGenerateSingleCode(int $code_length): void { $generator = new BackupCodeGenerator($code_length, 10); @@ -70,9 +69,7 @@ class BackupCodeGeneratorTest extends TestCase yield [10]; } - /** - * @dataProvider codeCountDataProvider - */ + #[DataProvider('codeCountDataProvider')] public function testGenerateCodeSet(int $code_count): void { $generator = new BackupCodeGenerator(8, $code_count); diff --git a/tests/Twig/UserExtensionTest.php b/tests/Twig/UserExtensionTest.php index ea024bda..21009f5e 100644 --- a/tests/Twig/UserExtensionTest.php +++ b/tests/Twig/UserExtensionTest.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Tests\Twig; +use PHPUnit\Framework\Attributes\DataProvider; use App\Twig\UserExtension; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -46,9 +47,7 @@ class UserExtensionTest extends WebTestCase yield ['/test/foo/bar?param1=val1¶m2=val2', '/de_DE/test/foo/bar?param1=val1¶m2=val2']; } - /** - * @dataProvider removeLocaleFromPathDataSet - */ + #[DataProvider('removeLocaleFromPathDataSet')] public function testRemoveLocaleFromPath(string $expected, string $input): void { $this->assertSame($expected, $this->service->removeLocaleFromPath($input));