Migrated phpunit annotations to attributes

This commit is contained in:
Jan Böhmer 2025-07-14 00:32:06 +02:00
parent f1d34bbc24
commit dc480f755c
50 changed files with 171 additions and 246 deletions

View file

@ -30,6 +30,10 @@ return RectorConfig::configure()
__DIR__ . '/tests', __DIR__ . '/tests',
]) ])
->withSets([
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
])
->withRules([ ->withRules([
DeclareStrictTypesRector::class DeclareStrictTypesRector::class
]) ])

View file

@ -23,15 +23,14 @@ declare(strict_types=1);
namespace App\Tests\API; namespace App\Tests\API;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class APIDocsAvailabilityTest extends WebTestCase class APIDocsAvailabilityTest extends WebTestCase
{ {
/** #[DataProvider('urlProvider')]
* @dataProvider urlProvider
*/
public function testDocAvailabilityForLoggedInUser(string $url): void public function testDocAvailabilityForLoggedInUser(string $url): void
{ {
self::ensureKernelShutdown(); self::ensureKernelShutdown();

View file

@ -22,20 +22,19 @@ declare(strict_types=1);
namespace App\Tests; namespace App\Tests;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\DataProvider;
use Generator; use Generator;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/** /**
* This test just ensures that different pages are available (do not throw an exception). * 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 class ApplicationAvailabilityFunctionalTest extends WebTestCase
{ {
/** #[DataProvider('urlProvider')]
* @dataProvider urlProvider
*/
public function testPageIsSuccessful(string $url): void public function testPageIsSuccessful(string $url): void
{ {
//We have localized routes //We have localized routes

View file

@ -22,13 +22,13 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
abstract class AbstractAdminControllerTest extends WebTestCase abstract class AbstractAdminControllerTest extends WebTestCase
{ {
protected static string $base_path = 'not_valid'; 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 * 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 public function testListEntries(string $user, bool $read): void
{ {
static::ensureKernelShutdown(); 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. * 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 public function testReadEntity(string $user, bool $read): void
{ {
//Test read access //Test read access
@ -106,10 +109,9 @@ abstract class AbstractAdminControllerTest extends WebTestCase
/** /**
* Tests if deleting an entity is working. * Tests if deleting an entity is working.
*
* @group slow
* @dataProvider deleteDataProvider
*/ */
#[DataProvider('deleteDataProvider')]
#[Group('slow')]
public function testDeleteEntity(string $user, bool $delete): void public function testDeleteEntity(string $user, bool $delete): void
{ {
//Test read access //Test read access

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class AttachmentTypeControllerTest extends AbstractAdminControllerTest class AttachmentTypeControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/attachment_type'; protected static string $base_path = '/en/attachment_type';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class CategoryControllerTest extends AbstractAdminControllerTest class CategoryControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/category'; protected static string $base_path = '/en/category';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Footprint; use App\Entity\Parts\Footprint;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class FootprintControllerTest extends AbstractAdminControllerTest class FootprintControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/footprint'; protected static string $base_path = '/en/footprint';

View file

@ -41,6 +41,8 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\LabelSystem\LabelProfile; use App\Entity\LabelSystem\LabelProfile;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@ -51,10 +53,9 @@ class LabelProfileControllerTest extends AbstractAdminControllerTest
/** /**
* Tests if deleting an entity is working. * Tests if deleting an entity is working.
*
* @group slow
* @dataProvider deleteDataProvider
*/ */
#[DataProvider('deleteDataProvider')]
#[Group('slow')]
public function testDeleteEntity(string $user, bool $delete): void public function testDeleteEntity(string $user, bool $delete): void
{ {
//Test read access //Test read access

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Manufacturer;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class ManufacturerControllerTest extends AbstractAdminControllerTest class ManufacturerControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/manufacturer'; protected static string $base_path = '/en/manufacturer';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\MeasurementUnit; use App\Entity\Parts\MeasurementUnit;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class MeasurementUnitControllerTest extends AbstractAdminControllerTest class MeasurementUnitControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/measurement_unit'; protected static string $base_path = '/en/measurement_unit';

View file

@ -23,12 +23,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\ProjectSystem\Project; use App\Entity\ProjectSystem\Project;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class ProjectControllerTest extends AbstractAdminControllerTest class ProjectControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/project'; protected static string $base_path = '/en/project';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\StorageLocation; use App\Entity\Parts\StorageLocation;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class StorelocationControllerTest extends AbstractAdminControllerTest class StorelocationControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/store_location'; protected static string $base_path = '/en/store_location';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages; namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Supplier; use App\Entity\Parts\Supplier;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class SupplierControllerTest extends AbstractAdminControllerTest class SupplierControllerTest extends AbstractAdminControllerTest
{ {
protected static string $base_path = '/en/supplier'; protected static string $base_path = '/en/supplier';

View file

@ -22,16 +22,17 @@ declare(strict_types=1);
namespace App\Tests\Controller; 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 Symfony\Bundle\FrameworkBundle\KernelBrowser;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/** #[Group('slow')]
* @group slow #[Group('DB')]
* @group DB
*/
class RedirectControllerTest extends WebTestCase class RedirectControllerTest extends WebTestCase
{ {
protected EntityManagerInterface $em; protected EntityManagerInterface $em;
@ -64,10 +65,9 @@ class RedirectControllerTest extends WebTestCase
/** /**
* Test if a certain request to an url will be redirected. * 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 public function testUrlMatch($url, $expect_redirect): void
{ {
//$client = static::createClient(); //$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. * 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 public function testAddLocale(?string $user_locale, string $input_path, string $redirect_path): void
{ {
//Redirect path is absolute //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. * 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. * 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 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 //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. * 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. * 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 public function testAddLocaleSubfolder(?string $user_locale, string $input_path, string $redirect_path): void
{ {
//Prefix our path with the proxy prefix //Prefix our path with the proxy prefix

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/ */
namespace App\Tests\DataTables\Filters\Constraints; namespace App\Tests\DataTables\Filters\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use App\DataTables\Filters\Constraints\FilterTrait; use App\DataTables\Filters\Constraints\FilterTrait;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -48,9 +49,7 @@ class FilterTraitTest extends TestCase
yield [true, 'MAX(attachments.value)']; yield [true, 'MAX(attachments.value)'];
} }
/** #[DataProvider('isAggregateFunctionStringDataProvider')]
* @dataProvider isAggregateFunctionStringDataProvider
*/
public function testIsAggregateFunctionString(bool $expected, string $input): void public function testIsAggregateFunctionString(bool $expected, string $input): void
{ {
$this->assertEquals($expected, $this->isAggregateFunctionString($input)); $this->assertEquals($expected, $this->isAggregateFunctionString($input));

View file

@ -41,13 +41,12 @@ declare(strict_types=1);
namespace App\Tests; namespace App\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DatatablesAvailabilityTest extends WebTestCase class DatatablesAvailabilityTest extends WebTestCase
{ {
/** #[DataProvider('urlProvider')]
* @dataProvider urlProvider
*/
public function testDataTable(string $url, ?array $ordering = null): void public function testDataTable(string $url, ?array $ordering = null): void
{ {
//We have localized routes //We have localized routes

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/ */
namespace App\Tests\Doctrine; namespace App\Tests\Doctrine;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Doctrine\Middleware\SQLiteRegexExtensionMiddlewareDriver; use App\Doctrine\Middleware\SQLiteRegexExtensionMiddlewareDriver;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -41,9 +42,7 @@ class SQLiteRegexMiddlewareTest extends TestCase
yield [1, '^a\d+$', 'a123']; yield [1, '^a\d+$', 'a123'];
} }
/** #[DataProvider('regexpDataProvider')]
* @dataProvider regexpDataProvider
*/
public function testRegexp(int $expected, string $pattern, string $value): void public function testRegexp(int $expected, string $pattern, string $value): void
{ {
$this->assertSame($expected, SQLiteRegexExtensionMiddlewareDriver::regexp($pattern, $value)); $this->assertSame($expected, SQLiteRegexExtensionMiddlewareDriver::regexp($pattern, $value));
@ -73,17 +72,13 @@ class SQLiteRegexMiddlewareTest extends TestCase
yield [6, 'c', ['b', 'a', 'b', 'a', 'b', 'c']]; 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 public function testField(int $expected, string|int|null $value, array $array): void
{ {
$this->assertSame($expected, SQLiteRegexExtensionMiddlewareDriver::field($value, ...$array)); $this->assertSame($expected, SQLiteRegexExtensionMiddlewareDriver::field($value, ...$array));
} }
/** #[DataProvider('fieldDataProvider')]
* @dataProvider fieldDataProvider
*/
public function testField2(int $expected, string|int|null $value, array $array): void public function testField2(int $expected, string|int|null $value, array $array): void
{ {
//Should be the same as field, but with the array comma imploded //Should be the same as field, but with the array comma imploded

View file

@ -22,6 +22,8 @@ declare(strict_types=1);
namespace App\Tests\Entity\Attachments; namespace App\Tests\Entity\Attachments;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Attachments\AttachmentTypeAttachment; use App\Entity\Attachments\AttachmentTypeAttachment;
@ -89,9 +91,7 @@ class AttachmentTest extends TestCase
yield [UserAttachment::class, User::class]; yield [UserAttachment::class, User::class];
} }
/** #[DataProvider('subClassesDataProvider')]
* @dataProvider subClassesDataProvider
*/
public function testSetElement(string $attachment_class, string $allowed_class): void public function testSetElement(string $attachment_class, string $allowed_class): void
{ {
/** @var Attachment $attachment */ /** @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 * Test that all attachment subclasses like PartAttachment or similar returns an exception, when a not allowed
* element is passed. * element is passed.
*
* @dataProvider subClassesDataProvider
* @depends testSetElement
*/ */
#[Depends('testSetElement')]
#[DataProvider('subClassesDataProvider')]
public function testSetElementExceptionOnSubClasses(string $attachment_class, string $allowed_class): void public function testSetElementExceptionOnSubClasses(string $attachment_class, string $allowed_class): void
{ {
$this->expectException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
@ -135,9 +134,7 @@ class AttachmentTest extends TestCase
yield [null, 'test.txt', null, null]; yield [null, 'test.txt', null, null];
} }
/** #[DataProvider('extensionDataProvider')]
* @dataProvider extensionDataProvider
*/
public function testGetExtension(?string $internal_path, ?string $external_path, ?string $originalFilename, ?string $expected): void public function testGetExtension(?string $internal_path, ?string $external_path, ?string $originalFilename, ?string $expected): void
{ {
$attachment = new PartAttachment(); $attachment = new PartAttachment();
@ -162,9 +159,7 @@ class AttachmentTest extends TestCase
yield ['%SECURE%/foo.txt/test', 'https://test.de/picture.jpeg', false]; 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 public function testIsPicture(?string $internal_path, ?string $external_path, bool $expected): void
{ {
$attachment = new PartAttachment(); $attachment = new PartAttachment();
@ -184,9 +179,7 @@ class AttachmentTest extends TestCase
yield ['%FOOTPRINTS%/foo/bar.txt', true]; yield ['%FOOTPRINTS%/foo/bar.txt', true];
} }
/** #[DataProvider('builtinDataProvider')]
* @dataProvider builtinDataProvider
*/
public function testIsBuiltIn(?string $path, $expected): void public function testIsBuiltIn(?string $path, $expected): void
{ {
$attachment = new PartAttachment(); $attachment = new PartAttachment();
@ -201,9 +194,7 @@ class AttachmentTest extends TestCase
yield ['https://foo.bar/test?txt=test', 'foo.bar']; yield ['https://foo.bar/test?txt=test', 'foo.bar'];
} }
/** #[DataProvider('hostDataProvider')]
* @dataProvider hostDataProvider
*/
public function testGetHost(?string $path, ?string $expected): void public function testGetHost(?string $path, ?string $expected): void
{ {
$attachment = new PartAttachment(); $attachment = new PartAttachment();
@ -219,9 +210,7 @@ class AttachmentTest extends TestCase
yield [null, 'https://www.google.de/test.txt', null, null]; 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 public function testGetFilename(?string $internal_path, ?string $external_path, ?string $original_filename, ?string $expected): void
{ {
$attachment = new PartAttachment(); $attachment = new PartAttachment();

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Entity\Parameters; namespace App\Tests\Entity\Parameters;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parameters\PartParameter; use App\Entity\Parameters\PartParameter;
use PHPUnit\Framework\TestCase; 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']; 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 public function testGetValueMinWithUnit(string $expected, float $value, string $unit): void
{ {
$param = new PartParameter(); $param = new PartParameter();
@ -91,9 +90,7 @@ class PartParameterTest extends TestCase
$this->assertSame($expected, $param->getValueMinWithUnit()); $this->assertSame($expected, $param->getValueMinWithUnit());
} }
/** #[DataProvider('valueWithUnitDataProvider')]
* @dataProvider valueWithUnitDataProvider
*/
public function testGetValueMaxWithUnit(string $expected, float $value, string $unit): void public function testGetValueMaxWithUnit(string $expected, float $value, string $unit): void
{ {
$param = new PartParameter(); $param = new PartParameter();
@ -102,9 +99,7 @@ class PartParameterTest extends TestCase
$this->assertSame($expected, $param->getValueMaxWithUnit()); $this->assertSame($expected, $param->getValueMaxWithUnit());
} }
/** #[DataProvider('valueWithUnitDataProvider')]
* @dataProvider valueWithUnitDataProvider
*/
public function testGetValueTypicalWithUnit(string $expected, float $value, string $unit): void public function testGetValueTypicalWithUnit(string $expected, float $value, string $unit): void
{ {
$param = new PartParameter(); $param = new PartParameter();
@ -114,12 +109,12 @@ class PartParameterTest extends TestCase
} }
/** /**
* @dataProvider formattedValueDataProvider
* *
* @param float $min * @param float $min
* @param float $typical * @param float $typical
* @param float $max * @param float $max
*/ */
#[DataProvider('formattedValueDataProvider')]
public function testGetFormattedValue(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void public function testGetFormattedValue(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void
{ {
$param = new PartParameter(); $param = new PartParameter();
@ -132,12 +127,12 @@ class PartParameterTest extends TestCase
} }
/** /**
* @dataProvider formattedValueWithLatexDataProvider
* *
* @param float $min * @param float $min
* @param float $typical * @param float $typical
* @param float $max * @param float $max
*/ */
#[DataProvider('formattedValueWithLatexDataProvider')]
public function testGetFormattedValueWithLatex(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void public function testGetFormattedValueWithLatex(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void
{ {
$param = new PartParameter(); $param = new PartParameter();

View file

@ -22,6 +22,8 @@ declare(strict_types=1);
namespace App\Tests\Entity\UserSystem; namespace App\Tests\Entity\UserSystem;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpunit;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use App\Entity\UserSystem\WebauthnKey; use App\Entity\UserSystem\WebauthnKey;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -52,9 +54,7 @@ class UserTest extends TestCase
yield ['SSSk38498', true]; yield ['SSSk38498', true];
} }
/** #[DataProvider('googleAuthenticatorEnabledDataProvider')]
* @dataProvider googleAuthenticatorEnabledDataProvider
*/
public function testIsGoogleAuthenticatorEnabled(?string $secret, bool $expected): void public function testIsGoogleAuthenticatorEnabled(?string $secret, bool $expected): void
{ {
$user = new User(); $user = new User();
@ -62,9 +62,7 @@ class UserTest extends TestCase
$this->assertSame($expected, $user->isGoogleAuthenticatorEnabled()); $this->assertSame($expected, $user->isGoogleAuthenticatorEnabled());
} }
/** #[RequiresPhpunit('8')]
* @requires PHPUnit 8
*/
public function testSetBackupCodes(): void public function testSetBackupCodes(): void
{ {
$user = new User(); $user = new User();

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Helpers; namespace App\Tests\Helpers;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Helpers\BBCodeToMarkdownConverter; use App\Helpers\BBCodeToMarkdownConverter;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -46,11 +47,11 @@ class BBCodeToMarkdownConverterTest extends TestCase
} }
/** /**
* @dataProvider dataProvider
* *
* @param $bbcode * @param $bbcode
* @param $expected * @param $expected
*/ */
#[DataProvider('dataProvider')]
public function testConvert($bbcode, $expected): void public function testConvert($bbcode, $expected): void
{ {
$this->assertSame($expected, $this->converter->convert($bbcode)); $this->assertSame($expected, $this->converter->convert($bbcode));

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/ */
namespace App\Tests\Helpers; namespace App\Tests\Helpers;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Helpers\IPAnonymizer; use App\Helpers\IPAnonymizer;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -36,9 +37,7 @@ class IPAnonymizerTest extends TestCase
yield ['fe80::', 'fe80::1fc4:15d8:78db:2319%enp4s0']; yield ['fe80::', 'fe80::1fc4:15d8:78db:2319%enp4s0'];
} }
/** #[DataProvider('anonymizeDataProvider')]
* @dataProvider anonymizeDataProvider
*/
public function testAnonymize(string $expected, string $input): void public function testAnonymize(string $expected, string $input): void
{ {
$this->assertSame($expected, IPAnonymizer::anonymize($input)); $this->assertSame($expected, IPAnonymizer::anonymize($input));

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/ */
namespace App\Tests\Serializer; namespace App\Tests\Serializer;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
use App\Serializer\StructuralElementDenormalizer; use App\Serializer\StructuralElementDenormalizer;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 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])); $this->assertTrue($this->service->supportsDenormalization(['name' => 'Test'], Category::class, 'json', ['groups' => ['import'], 'partdb_import' => true]));
} }
/** #[Group('DB')]
* @group DB
*/
public function testDenormalize(): void public function testDenormalize(): void
{ {
//Check that we retrieve DB elements via the name //Check that we retrieve DB elements via the name

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Attachments; namespace App\Tests\Services\Attachments;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\Formatters\AmountFormatter; use App\Services\Formatters\AmountFormatter;
use App\Services\Attachments\AttachmentPathResolver; use App\Services\Attachments\AttachmentPathResolver;
use const DIRECTORY_SEPARATOR; use const DIRECTORY_SEPARATOR;
@ -119,17 +120,13 @@ class AttachmentPathResolverTest extends WebTestCase
yield ['/not/root'.$this->footprint_path, null]; yield ['/not/root'.$this->footprint_path, null];
} }
/** #[DataProvider('placeholderDataProvider')]
* @dataProvider placeholderDataProvider
*/
public function testPlaceholderToRealPath($param, $expected): void public function testPlaceholderToRealPath($param, $expected): void
{ {
$this->assertSame($expected, $this->service->placeholderToRealPath($param)); $this->assertSame($expected, $this->service->placeholderToRealPath($param));
} }
/** #[DataProvider('realPathDataProvider')]
* @dataProvider realPathDataProvider
*/
public function testRealPathToPlaceholder($param, $expected, $old_method = false): void public function testRealPathToPlaceholder($param, $expected, $old_method = false): void
{ {
$this->assertSame($expected, $this->service->realPathToPlaceholder($param, $old_method)); $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']; 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 public function testConversionOfGermanFootprintPaths(string $expected, string $input): void
{ {
$this->assertSame($expected, $this->service->placeholderToRealPath($input)); $this->assertSame($expected, $this->service->placeholderToRealPath($input));

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Attachments; namespace App\Tests\Services\Attachments;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\Attachments\AttachmentURLGenerator; use App\Services\Attachments\AttachmentURLGenerator;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -48,11 +49,11 @@ class AttachmentURLGeneratorTest extends WebTestCase
} }
/** /**
* @dataProvider dataProvider
* *
* @param $input * @param $input
* @param $expected * @param $expected
*/ */
#[DataProvider('dataProvider')]
public function testTestabsolutePathToAssetPath($input, $expected): void public function testTestabsolutePathToAssetPath($input, $expected): void
{ {
$this->assertSame($expected, static::$service->absolutePathToAssetPath($input, static::PUBLIC_DIR)); $this->assertSame($expected, static::$service->absolutePathToAssetPath($input, static::PUBLIC_DIR));

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Attachments; namespace App\Tests\Services\Attachments;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\Attachments\BuiltinAttachmentsFinder; use App\Services\Attachments\BuiltinAttachmentsFinder;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -54,9 +55,7 @@ class BuiltinAttachmentsFinderTest extends WebTestCase
yield ['.txt', [], ['%FOOTPRINTS_3D%/hallo.txt']]; yield ['.txt', [], ['%FOOTPRINTS_3D%/hallo.txt']];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testFind($keyword, $options, $expected): void public function testFind($keyword, $options, $expected): void
{ {
$value = static::$service->find($keyword, $options, static::$mock_list); $value = static::$service->find($keyword, $options, static::$mock_list);

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Attachments; namespace App\Tests\Services\Attachments;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\Attachments\FileTypeFilterTools; use App\Services\Attachments\FileTypeFilterTools;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -85,25 +86,20 @@ class FileTypeFilterToolsTest extends WebTestCase
/** /**
* Test the validateFilterString method. * Test the validateFilterString method.
*
* @dataProvider validateDataProvider
*/ */
#[DataProvider('validateDataProvider')]
public function testValidateFilterString(string $filter, bool $expected): void public function testValidateFilterString(string $filter, bool $expected): void
{ {
$this->assertSame($expected, self::$service->validateFilterString($filter)); $this->assertSame($expected, self::$service->validateFilterString($filter));
} }
/** #[DataProvider('normalizeDataProvider')]
* @dataProvider normalizeDataProvider
*/
public function testNormalizeFilterString(string $filter, string $expected): void public function testNormalizeFilterString(string $filter, string $expected): void
{ {
$this->assertSame($expected, self::$service->normalizeFilterString($filter)); $this->assertSame($expected, self::$service->normalizeFilterString($filter));
} }
/** #[DataProvider('extensionAllowedDataProvider')]
* @dataProvider extensionAllowedDataProvider
*/
public function testIsExtensionAllowed(string $filter, string $extension, bool $expected): void public function testIsExtensionAllowed(string $filter, string $extension, bool $expected): void
{ {
$this->assertSame($expected, self::$service->isExtensionAllowed($filter, $extension)); $this->assertSame($expected, self::$service->isExtensionAllowed($filter, $extension));

View file

@ -22,6 +22,8 @@ declare(strict_types=1);
namespace App\Tests\Services\ImportExportSystem; namespace App\Tests\Services\ImportExportSystem;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Attachments\AttachmentContainingDBElement;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\LabelSystem\LabelProfile; use App\Entity\LabelSystem\LabelProfile;
@ -35,9 +37,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\ConstraintViolationListInterface;
/** #[Group('DB')]
* @group DB
*/
class EntityImporterTest extends WebTestCase class EntityImporterTest extends WebTestCase
{ {
/** /**
@ -184,9 +184,7 @@ EOT;
yield ['yaml', 'YAML']; yield ['yaml', 'YAML'];
} }
/** #[DataProvider('formatDataProvider')]
* @dataProvider formatDataProvider
*/
public function testDetermineFormat(string $expected, string $extension): void public function testDetermineFormat(string $expected, string $extension): void
{ {
$this->assertSame($expected, $this->service->determineFormat($extension)); $this->assertSame($expected, $this->service->determineFormat($extension));

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/ */
namespace App\Tests\Services\InfoProviderSystem\DTOs; namespace App\Tests\Services\InfoProviderSystem\DTOs;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\InfoProviderSystem\DTOs\FileDTO; use App\Services\InfoProviderSystem\DTOs\FileDTO;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -40,9 +41,7 @@ class FileDTOTest extends TestCase
yield ["test%7Cse", "test|se"]; yield ["test%7Cse", "test|se"];
} }
/** #[DataProvider('escapingDataProvider')]
* @dataProvider escapingDataProvider
*/
public function testURLEscaping(string $expected, string $input): void public function testURLEscaping(string $expected, string $input): void
{ {
$fileDTO = new FileDTO( $input); $fileDTO = new FileDTO( $input);

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/ */
namespace App\Tests\Services\InfoProviderSystem\DTOs; namespace App\Tests\Services\InfoProviderSystem\DTOs;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\InfoProviderSystem\DTOs\ParameterDTO; use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -234,18 +235,18 @@ class ParameterDTOTest extends TestCase
} }
/** /**
* @dataProvider parseValueFieldDataProvider
* @return void * @return void
*/ */
#[DataProvider('parseValueFieldDataProvider')]
public function testParseValueField(ParameterDTO $expected, string $name, string|float $value, ?string $unit = null, ?string $symbol = null, ?string $group = null) 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)); $this->assertEquals($expected, ParameterDTO::parseValueField($name, $value, $unit, $symbol, $group));
} }
/** /**
* @dataProvider parseValueIncludingUnitDataProvider
* @return void * @return void
*/ */
#[DataProvider('parseValueIncludingUnitDataProvider')]
public function testParseValueIncludingUnit(ParameterDTO $expected, string $name, string|float $value, ?string $symbol = null, ?string $group = null) 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)); $this->assertEquals($expected, ParameterDTO::parseValueIncludingUnit($name, $value, $symbol, $group));

View file

@ -41,6 +41,8 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\BarcodeScanner; namespace App\Tests\Services\LabelSystem\BarcodeScanner;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\LabelSystem\LabelSupportedElement; use App\Entity\LabelSystem\LabelSupportedElement;
use App\Services\LabelSystem\BarcodeScanner\BarcodeRedirector; use App\Services\LabelSystem\BarcodeScanner\BarcodeRedirector;
use App\Services\LabelSystem\BarcodeScanner\BarcodeSourceType; 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']; yield [new LocalBarcodeScanResult(LabelSupportedElement::STORELOCATION, 1, BarcodeSourceType::INTERNAL), '/en/store_location/1/parts'];
} }
/** #[DataProvider('urlDataProvider')]
* @dataProvider urlDataProvider #[Group('DB')]
* @group DB
*/
public function testGetRedirectURL(LocalBarcodeScanResult $scanResult, string $url): void public function testGetRedirectURL(LocalBarcodeScanResult $scanResult, string $url): void
{ {
$this->assertSame($url, $this->service->getRedirectURL($scanResult)); $this->assertSame($url, $this->service->getRedirectURL($scanResult));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\BarcodeScanner; namespace App\Tests\Services\LabelSystem\BarcodeScanner;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\LabelSystem\LabelSupportedElement; use App\Entity\LabelSystem\LabelSupportedElement;
use App\Services\LabelSystem\BarcodeScanner\BarcodeScanHelper; use App\Services\LabelSystem\BarcodeScanner\BarcodeScanHelper;
use App\Services\LabelSystem\BarcodeScanner\BarcodeScanResultInterface; use App\Services\LabelSystem\BarcodeScanner\BarcodeScanResultInterface;
@ -140,17 +141,13 @@ class BarcodeScanHelperTest extends WebTestCase
yield ['']; yield [''];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testNormalizeBarcodeContent(BarcodeScanResultInterface $expected, string $input): void public function testNormalizeBarcodeContent(BarcodeScanResultInterface $expected, string $input): void
{ {
$this->assertEquals($expected, $this->service->scanBarcodeContent($input)); $this->assertEquals($expected, $this->service->scanBarcodeContent($input));
} }
/** #[DataProvider('invalidDataProvider')]
* @dataProvider invalidDataProvider
*/
public function testInvalidFormats(string $input): void public function testInvalidFormats(string $input): void
{ {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\Barcodes; namespace App\Tests\Services\LabelSystem\Barcodes;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot; use App\Entity\Parts\PartLot;
use App\Entity\Parts\StorageLocation; use App\Entity\Parts\StorageLocation;
@ -71,17 +72,13 @@ class BarcodeContentGeneratorTest extends KernelTestCase
yield ['/scan/location/0', StorageLocation::class]; yield ['/scan/location/0', StorageLocation::class];
} }
/** #[DataProvider('Barcode1DDataProvider')]
* @dataProvider Barcode1DDataProvider
*/
public function testGet1DBarcodeContent(string $expected, string $class): void public function testGet1DBarcodeContent(string $expected, string $class): void
{ {
$this->assertSame($expected, $this->service->get1DBarcodeContent(new $class())); $this->assertSame($expected, $this->service->get1DBarcodeContent(new $class()));
} }
/** #[DataProvider('Barcode2DDataProvider')]
* @dataProvider Barcode2DDataProvider
*/
public function testGetURLContent(string $expected, string $class): void public function testGetURLContent(string $expected, string $class): void
{ {
$url = $this->service->getURLContent(new $class()); $url = $this->service->getURLContent(new $class());

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem; namespace App\Tests\Services\LabelSystem;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractDBElement;
use App\Entity\LabelSystem\LabelOptions; use App\Entity\LabelSystem\LabelOptions;
use App\Entity\LabelSystem\LabelSupportedElement; use App\Entity\LabelSystem\LabelSupportedElement;
@ -70,9 +71,7 @@ class LabelGeneratorTest extends WebTestCase
yield [LabelSupportedElement::STORELOCATION, StorageLocation::class]; yield [LabelSupportedElement::STORELOCATION, StorageLocation::class];
} }
/** #[DataProvider('supportsDataProvider')]
* @dataProvider supportsDataProvider
*/
public function testSupports(LabelSupportedElement $type, string $class): void public function testSupports(LabelSupportedElement $type, string $class): void
{ {
$options = new LabelOptions(); $options = new LabelOptions();

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem; namespace App\Tests\Services\LabelSystem;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot; use App\Entity\Parts\PartLot;
use App\Services\LabelSystem\LabelTextReplacer; use App\Services\LabelSystem\LabelTextReplacer;
@ -94,17 +95,13 @@ class LabelTextReplacerTest extends WebTestCase
yield ['TEST[[ ]]TEST', 'TEST[[ ]]TEST']; yield ['TEST[[ ]]TEST', 'TEST[[ ]]TEST'];
} }
/** #[DataProvider('handlePlaceholderDataProvider')]
* @dataProvider handlePlaceholderDataProvider
*/
public function testHandlePlaceholder(string $expected, string $input): void public function testHandlePlaceholder(string $expected, string $input): void
{ {
$this->assertSame($expected, $this->service->handlePlaceholder($input, $this->target)); $this->assertSame($expected, $this->service->handlePlaceholder($input, $this->target));
} }
/** #[DataProvider('replaceDataProvider')]
* @dataProvider replaceDataProvider
*/
public function testReplace(string $expected, string $input): void public function testReplace(string $expected, string $input): void
{ {
$this->assertSame($expected, $this->service->replace($input, $this->target)); $this->assertSame($expected, $this->service->replace($input, $this->target));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\PlaceholderProviders; namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractDBElement;
use App\Services\LabelSystem\PlaceholderProviders\AbstractDBElementProvider; use App\Services\LabelSystem\PlaceholderProviders\AbstractDBElementProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -68,9 +69,7 @@ class AbstractElementProviderTest extends WebTestCase
yield ['123', '[[ID]]']; yield ['123', '[[ID]]'];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testReplace(string $expected, string $placeholder): void public function testReplace(string $expected, string $placeholder): void
{ {
$this->assertSame($expected, $this->service->replace($placeholder, $this->target)); $this->assertSame($expected, $this->service->replace($placeholder, $this->target));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\PlaceholderProviders; namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Services\LabelSystem\PlaceholderProviders\GlobalProviders; use App\Services\LabelSystem\PlaceholderProviders\GlobalProviders;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -67,9 +68,7 @@ class GlobalProvidersTest extends WebTestCase
yield ['anonymous', '[[USERNAME]]']; yield ['anonymous', '[[USERNAME]]'];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testReplace(string $expected, string $placeholder): void public function testReplace(string $expected, string $placeholder): void
{ {
$this->assertSame($expected, $this->service->replace($placeholder, $this->target)); $this->assertSame($expected, $this->service->replace($placeholder, $this->target));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\PlaceholderProviders; namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Contracts\NamedElementInterface; use App\Entity\Contracts\NamedElementInterface;
use App\Services\LabelSystem\PlaceholderProviders\NamedElementProvider; use App\Services\LabelSystem\PlaceholderProviders\NamedElementProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -71,9 +72,7 @@ class NamedElementProviderTest extends WebTestCase
yield ['This is my Name', '[[NAME]]']; yield ['This is my Name', '[[NAME]]'];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testReplace(string $expected, string $placeholder): void public function testReplace(string $expected, string $placeholder): void
{ {
$this->assertSame($expected, $this->service->replace($placeholder, $this->target)); $this->assertSame($expected, $this->service->replace($placeholder, $this->target));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\PlaceholderProviders; namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot; use App\Entity\Parts\PartLot;
use App\Entity\Parts\StorageLocation; use App\Entity\Parts\StorageLocation;
@ -101,9 +102,7 @@ class PartLotProviderTest extends WebTestCase
yield ['user', '[[OWNER_USERNAME]]']; yield ['user', '[[OWNER_USERNAME]]'];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testReplace(string $expected, string $placeholder): void public function testReplace(string $expected, string $placeholder): void
{ {
$this->assertSame($expected, $this->service->replace($placeholder, $this->target)); $this->assertSame($expected, $this->service->replace($placeholder, $this->target));

View file

@ -41,6 +41,8 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\PlaceholderProviders; namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parts\ManufacturingStatus; use App\Entity\Parts\ManufacturingStatus;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
@ -50,9 +52,7 @@ use App\Services\LabelSystem\PlaceholderProviders\PartProvider;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/** #[Group('DB')]
* @group DB
*/
class PartProviderTest extends WebTestCase class PartProviderTest extends WebTestCase
{ {
/** /**
@ -105,9 +105,7 @@ class PartProviderTest extends WebTestCase
yield ['Bold Italic', '[[COMMENT_T]]']; yield ['Bold Italic', '[[COMMENT_T]]'];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testReplace(string $expected, string $placeholder): void public function testReplace(string $expected, string $placeholder): void
{ {
$this->assertSame($expected, $this->service->replace($placeholder, $this->target)); $this->assertSame($expected, $this->service->replace($placeholder, $this->target));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem\PlaceholderProviders; namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Contracts\TimeStampableInterface; use App\Entity\Contracts\TimeStampableInterface;
use App\Services\LabelSystem\PlaceholderProviders\GlobalProviders; use App\Services\LabelSystem\PlaceholderProviders\GlobalProviders;
use App\Services\LabelSystem\PlaceholderProviders\TimestampableElementProvider; use App\Services\LabelSystem\PlaceholderProviders\TimestampableElementProvider;
@ -81,9 +82,7 @@ class TimestampableElementProviderTest extends WebTestCase
yield ['1/1/00, 12:00 AM', '[[CREATION_DATE]]']; yield ['1/1/00, 12:00 AM', '[[CREATION_DATE]]'];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testReplace(string $expected, string $placeholder): void public function testReplace(string $expected, string $placeholder): void
{ {
$this->assertSame($expected, $this->service->replace($placeholder, $this->target)); $this->assertSame($expected, $this->service->replace($placeholder, $this->target));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\LabelSystem; namespace App\Tests\Services\LabelSystem;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\LabelSystem\LabelOptions; use App\Entity\LabelSystem\LabelOptions;
use App\Entity\LabelSystem\LabelProcessMode; use App\Entity\LabelSystem\LabelProcessMode;
use App\Entity\LabelSystem\LabelSupportedElement; use App\Entity\LabelSystem\LabelSupportedElement;
@ -103,9 +104,7 @@ class SandboxedTwigFactoryTest extends WebTestCase
yield ['{{ part.setCategory(null) }}']; yield ['{{ part.setCategory(null) }}'];
} }
/** #[DataProvider('twigDataProvider')]
* @dataProvider twigDataProvider
*/
public function testTwigFeatures(string $twig): void public function testTwigFeatures(string $twig): void
{ {
$options = new LabelOptions(); $options = new LabelOptions();
@ -123,9 +122,7 @@ class SandboxedTwigFactoryTest extends WebTestCase
$this->assertIsString($str); $this->assertIsString($str);
} }
/** #[DataProvider('twigNotAllowedDataProvider')]
* @dataProvider twigNotAllowedDataProvider
*/
public function testTwigForbidden(string $twig): void public function testTwigForbidden(string $twig): void
{ {
$this->expectException(SecurityError::class); $this->expectException(SecurityError::class);

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Misc; namespace App\Tests\Services\Misc;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\Misc\FAIconGenerator; use App\Services\Misc\FAIconGenerator;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -95,9 +96,7 @@ class FAIconGeneratorTest extends WebTestCase
yield ['fgd', 'fa-file']; yield ['fgd', 'fa-file'];
} }
/** #[DataProvider('fileExtensionDataProvider')]
* @dataProvider fileExtensionDataProvider
*/
public function testFileExtensionToFAType(string $ext, string $expected): void public function testFileExtensionToFAType(string $ext, string $expected): void
{ {
$this->assertSame($expected, $this->service->fileExtensionToFAType($ext), 'Failed for extension .'.$ext); $this->assertSame($expected, $this->service->fileExtensionToFAType($ext), 'Failed for extension .'.$ext);

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Misc; namespace App\Tests\Services\Misc;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\Misc\RangeParser; use App\Services\Misc\RangeParser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -96,9 +97,7 @@ class RangeParserTest extends WebTestCase
yield [false, '1, 2 test']; yield [false, '1, 2 test'];
} }
/** #[DataProvider('dataProvider')]
* @dataProvider dataProvider
*/
public function testParse(array $expected, string $input, bool $must_throw = false): void public function testParse(array $expected, string $input, bool $must_throw = false): void
{ {
if ($must_throw) { if ($must_throw) {
@ -109,9 +108,7 @@ class RangeParserTest extends WebTestCase
} }
} }
/** #[DataProvider('validDataProvider')]
* @dataProvider validDataProvider
*/
public function testIsValidRange(bool $expected, string $input): void public function testIsValidRange(bool $expected, string $input): void
{ {
$this->assertSame($expected, $this->service->isValidRange($input)); $this->assertSame($expected, $this->service->isValidRange($input));

View file

@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Parameters; namespace App\Tests\Services\Parameters;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parameters\AbstractParameter; use App\Entity\Parameters\AbstractParameter;
use App\Services\Parameters\ParameterExtractor; use App\Services\Parameters\ParameterExtractor;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 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']; yield ['A [link](https://demo.part-db.de) should not be matched'];
} }
/** #[DataProvider('emptyDataProvider')]
* @dataProvider emptyDataProvider
*/
public function testShouldReturnEmpty(string $input): void public function testShouldReturnEmpty(string $input): void
{ {
$this->assertEmpty($this->service->extractParameters($input)); $this->assertEmpty($this->service->extractParameters($input));

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Parts; namespace App\Tests\Services\Parts;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Entity\PriceInformations\Orderdetail; use App\Entity\PriceInformations\Orderdetail;
use App\Entity\PriceInformations\Pricedetail; use App\Entity\PriceInformations\Pricedetail;
@ -81,9 +82,7 @@ class PricedetailHelperTest extends WebTestCase
yield [$part, 10.0, 'Part with multiple orderdetails failed']; yield [$part, 10.0, 'Part with multiple orderdetails failed'];
} }
/** #[DataProvider('maxDiscountAmountDataProvider')]
* @dataProvider maxDiscountAmountDataProvider
*/
public function testGetMaxDiscountAmount(Part $part, ?float $expected_result, string $message): void public function testGetMaxDiscountAmount(Part $part, ?float $expected_result, string $message): void
{ {
$this->assertSame($expected_result, $this->service->getMaxDiscountAmount($part), $message); $this->assertSame($expected_result, $this->service->getMaxDiscountAmount($part), $message);

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\Trees; namespace App\Tests\Services\Trees;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
use App\Helpers\Trees\TreeViewNode; use App\Helpers\Trees\TreeViewNode;
@ -29,9 +30,7 @@ use App\Services\Trees\TreeViewGenerator;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/** #[Group('DB')]
* @group DB
*/
class TreeViewGeneratorTest extends WebTestCase class TreeViewGeneratorTest extends WebTestCase
{ {
protected $em; protected $em;

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\UserSystem; namespace App\Tests\Services\UserSystem;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Entity\UserSystem\Group; use App\Entity\UserSystem\Group;
use App\Entity\UserSystem\PermissionData; use App\Entity\UserSystem\PermissionData;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
@ -101,9 +102,7 @@ class PermissionManagerTest extends WebTestCase
yield ['tools']; yield ['tools'];
} }
/** #[DataProvider('getPermissionNames')]
* @dataProvider getPermissionNames
*/
public function testListOperationsForPermission($perm_name): void public function testListOperationsForPermission($perm_name): void
{ {
$arr = $this->service->listOperationsForPermission($perm_name); $arr = $this->service->listOperationsForPermission($perm_name);

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Tests\Services\UserSystem\TFA; namespace App\Tests\Services\UserSystem\TFA;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Services\UserSystem\TFA\BackupCodeGenerator; use App\Services\UserSystem\TFA\BackupCodeGenerator;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use RuntimeException; use RuntimeException;
@ -54,9 +55,7 @@ class BackupCodeGeneratorTest extends TestCase
yield [16]; yield [16];
} }
/** #[DataProvider('codeLengthDataProvider')]
* @dataProvider codeLengthDataProvider
*/
public function testGenerateSingleCode(int $code_length): void public function testGenerateSingleCode(int $code_length): void
{ {
$generator = new BackupCodeGenerator($code_length, 10); $generator = new BackupCodeGenerator($code_length, 10);
@ -70,9 +69,7 @@ class BackupCodeGeneratorTest extends TestCase
yield [10]; yield [10];
} }
/** #[DataProvider('codeCountDataProvider')]
* @dataProvider codeCountDataProvider
*/
public function testGenerateCodeSet(int $code_count): void public function testGenerateCodeSet(int $code_count): void
{ {
$generator = new BackupCodeGenerator(8, $code_count); $generator = new BackupCodeGenerator(8, $code_count);

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/ */
namespace App\Tests\Twig; namespace App\Tests\Twig;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Twig\UserExtension; use App\Twig\UserExtension;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -46,9 +47,7 @@ class UserExtensionTest extends WebTestCase
yield ['/test/foo/bar?param1=val1&param2=val2', '/de_DE/test/foo/bar?param1=val1&param2=val2']; yield ['/test/foo/bar?param1=val1&param2=val2', '/de_DE/test/foo/bar?param1=val1&param2=val2'];
} }
/** #[DataProvider('removeLocaleFromPathDataSet')]
* @dataProvider removeLocaleFromPathDataSet
*/
public function testRemoveLocaleFromPath(string $expected, string $input): void public function testRemoveLocaleFromPath(string $expected, string $input): void
{ {
$this->assertSame($expected, $this->service->removeLocaleFromPath($input)); $this->assertSame($expected, $this->service->removeLocaleFromPath($input));