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',
])
->withSets([
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
])
->withRules([
DeclareStrictTypesRector::class
])

View file

@ -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();

View file

@ -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

View file

@ -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

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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

View file

@ -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));

View file

@ -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

View file

@ -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

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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));

View file

@ -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));

View file

@ -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

View file

@ -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));

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -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);

View file

@ -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());

View file

@ -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();

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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);

View file

@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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&param2=val2', '/de_DE/test/foo/bar?param1=val1&param2=val2'];
}
/**
* @dataProvider removeLocaleFromPathDataSet
*/
#[DataProvider('removeLocaleFromPathDataSet')]
public function testRemoveLocaleFromPath(string $expected, string $input): void
{
$this->assertSame($expected, $this->service->removeLocaleFromPath($input));