diff --git a/config/packages/doctrine.php b/config/packages/doctrine.php index e5be011f..47584ed7 100644 --- a/config/packages/doctrine.php +++ b/config/packages/doctrine.php @@ -20,14 +20,12 @@ declare(strict_types=1); -use Symfony\Config\DoctrineConfig; - /** * This class extends the default doctrine ORM configuration to enable native lazy objects on PHP 8.4+. * We have to do this in a PHP file, because the yaml file does not support conditionals on PHP version. */ -return static function(DoctrineConfig $doctrine) { +return static function(\Symfony\Config\DoctrineConfig $doctrine) { //On PHP 8.4+ we can use native lazy objects, which are much more efficient than proxies. if (PHP_VERSION_ID >= 80400) { $doctrine->orm()->enableNativeLazyObjects(true); diff --git a/rector.php b/rector.php index 5a77a882..936b447e 100644 --- a/rector.php +++ b/rector.php @@ -18,7 +18,7 @@ use Rector\Symfony\Set\SymfonySetList; use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; return RectorConfig::configure() - ->withComposerBased(phpunit: true, symfony: true) + ->withComposerBased(phpunit: true) ->withSymfonyContainerPhp(__DIR__ . '/tests/symfony-container.php') ->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml') @@ -36,6 +36,8 @@ return RectorConfig::configure() PHPUnitSetList::PHPUNIT_90, PHPUnitSetList::PHPUNIT_110, PHPUnitSetList::PHPUNIT_CODE_QUALITY, + + ]) ->withRules([ @@ -57,9 +59,6 @@ return RectorConfig::configure() PreferPHPUnitThisCallRector::class, //Do not replace 'GET' with class constant, LiteralGetToRequestClassConstantRector::class, - - //Do not move help text of commands to the command class, as we want to keep the help text in the command definition for better readability - \Rector\Symfony\Symfony73\Rector\Class_\CommandHelpToAttributeRector::class ]) //Do not apply rules to Symfony own files @@ -68,7 +67,6 @@ return RectorConfig::configure() __DIR__ . '/src/Kernel.php', __DIR__ . '/config/preload.php', __DIR__ . '/config/bundles.php', - __DIR__ . '/config/reference.php' ]) ; diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index b4f46a27..d9fcd7f1 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace App\Controller; -use App\Entity\InfoProviderSystem\BulkInfoProviderImportJob; use App\DataTables\LogDataTable; use App\Entity\Attachments\AttachmentUpload; use App\Entity\Parts\Category; @@ -152,7 +151,7 @@ final class PartController extends AbstractController $jobId = $request->query->get('jobId'); $bulkJob = null; if ($jobId) { - $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); // Verify user owns this job if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) { $bulkJob = null; @@ -173,7 +172,7 @@ final class PartController extends AbstractController throw $this->createAccessDeniedException('Invalid CSRF token'); } - $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); if (!$bulkJob || $bulkJob->getCreatedBy() !== $this->getUser()) { throw $this->createNotFoundException('Bulk import job not found'); } @@ -339,7 +338,7 @@ final class PartController extends AbstractController $jobId = $request->query->get('jobId'); $bulkJob = null; if ($jobId) { - $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); // Verify user owns this job if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) { $bulkJob = null; diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index ad4d272f..4e2077c4 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -147,7 +147,10 @@ class SecurityController extends AbstractController 'label' => 'user.settings.pw_confirm.label', ], 'invalid_message' => 'password_must_match', - 'constraints' => [new Length(min: 6, max: 128)], + 'constraints' => [new Length([ + 'min' => 6, + 'max' => 128, + ])], ]); $builder->add('submit', SubmitType::class, [ diff --git a/src/Controller/UserSettingsController.php b/src/Controller/UserSettingsController.php index 3f54e99c..4e56015a 100644 --- a/src/Controller/UserSettingsController.php +++ b/src/Controller/UserSettingsController.php @@ -295,7 +295,10 @@ class UserSettingsController extends AbstractController 'autocomplete' => 'new-password', ], ], - 'constraints' => [new Length(min: 6, max: 128)], + 'constraints' => [new Length([ + 'min' => 6, + 'max' => 128, + ])], ]) ->add('submit', SubmitType::class, [ 'label' => 'save', diff --git a/src/DataTables/Filters/PartSearchFilter.php b/src/DataTables/Filters/PartSearchFilter.php index 9f6734e5..c0951d3a 100644 --- a/src/DataTables/Filters/PartSearchFilter.php +++ b/src/DataTables/Filters/PartSearchFilter.php @@ -160,7 +160,7 @@ class PartSearchFilter implements FilterInterface if ($search_dbId) { $expressions[] = $queryBuilder->expr()->eq('part.id', ':id_exact'); $queryBuilder->setParameter('id_exact', (int) $this->keyword, - ParameterType::INTEGER); + \Doctrine\DBAL\ParameterType::INTEGER); } //Guard condition diff --git a/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php b/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php index 690448a5..ecc25b4f 100644 --- a/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php +++ b/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php @@ -1,7 +1,5 @@ [ //new AllowedFileExtension(), - new File(maxSize: $options['max_file_size']), + new File([ + 'maxSize' => $options['max_file_size'], + ]), ], ]); diff --git a/src/Form/InfoProviderSystem/FieldToProviderMappingType.php b/src/Form/InfoProviderSystem/FieldToProviderMappingType.php index 7df8985e..13e9581e 100644 --- a/src/Form/InfoProviderSystem/FieldToProviderMappingType.php +++ b/src/Form/InfoProviderSystem/FieldToProviderMappingType.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace App\Form\InfoProviderSystem; -use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; @@ -62,7 +61,7 @@ class FieldToProviderMappingType extends AbstractType 'style' => 'width: 80px;' ], 'constraints' => [ - new Range(min: 1, max: 10), + new \Symfony\Component\Validator\Constraints\Range(['min' => 1, 'max' => 10]), ], ]); } diff --git a/src/Form/UserAdminForm.php b/src/Form/UserAdminForm.php index 457a6e0b..69be181f 100644 --- a/src/Form/UserAdminForm.php +++ b/src/Form/UserAdminForm.php @@ -177,7 +177,10 @@ class UserAdminForm extends AbstractType 'required' => false, 'mapped' => false, 'disabled' => !$this->security->isGranted('set_password', $entity) || $entity->isSamlUser(), - 'constraints' => [new Length(min: 6, max: 128)], + 'constraints' => [new Length([ + 'min' => 6, + 'max' => 128, + ])], ]) ->add('need_pw_change', CheckboxType::class, [ diff --git a/src/Form/UserSettingsType.php b/src/Form/UserSettingsType.php index 968d8063..0c7cb169 100644 --- a/src/Form/UserSettingsType.php +++ b/src/Form/UserSettingsType.php @@ -92,7 +92,9 @@ class UserSettingsType extends AbstractType 'accept' => 'image/*', ], 'constraints' => [ - new File(maxSize: '5M'), + new File([ + 'maxSize' => '5M', + ]), ], ]) ->add('aboutMe', RichTextEditorType::class, [ diff --git a/src/Services/ImportExportSystem/BOMImporter.php b/src/Services/ImportExportSystem/BOMImporter.php index abf72d74..8a91c825 100644 --- a/src/Services/ImportExportSystem/BOMImporter.php +++ b/src/Services/ImportExportSystem/BOMImporter.php @@ -22,8 +22,6 @@ declare(strict_types=1); */ namespace App\Services\ImportExportSystem; -use App\Entity\Parts\Supplier; -use App\Entity\PriceInformations\Orderdetail; use App\Entity\Parts\Part; use App\Entity\ProjectSystem\Project; use App\Entity\ProjectSystem\ProjectBOMEntry; @@ -277,7 +275,7 @@ class BOMImporter $mapped_entries = []; // Collect all mapped entries for validation // Fetch suppliers once for efficiency - $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); $supplierSPNKeys = []; $suppliersByName = []; // Map supplier names to supplier objects foreach ($suppliers as $supplier) { @@ -373,7 +371,7 @@ class BOMImporter if ($supplier_spn !== null) { // Query for orderdetails with matching supplier and SPN - $orderdetail = $this->entityManager->getRepository(Orderdetail::class) + $orderdetail = $this->entityManager->getRepository(\App\Entity\PriceInformations\Orderdetail::class) ->findOneBy([ 'supplier' => $supplier, 'supplierpartnr' => $supplier_spn, @@ -537,7 +535,7 @@ class BOMImporter ]; // Add dynamic supplier fields based on available suppliers in the database - $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); foreach ($suppliers as $supplier) { $supplierName = $supplier->getName(); $targets[$supplierName . ' SPN'] = [ @@ -572,7 +570,7 @@ class BOMImporter ]; // Add supplier-specific patterns - $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); foreach ($suppliers as $supplier) { $supplierName = $supplier->getName(); $supplierLower = strtolower($supplierName); diff --git a/src/Services/ImportExportSystem/EntityExporter.php b/src/Services/ImportExportSystem/EntityExporter.php index 9ed027ae..70feb8e6 100644 --- a/src/Services/ImportExportSystem/EntityExporter.php +++ b/src/Services/ImportExportSystem/EntityExporter.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace App\Services\ImportExportSystem; -use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractStructuralDBElement; use App\Helpers\FilenameSanatizer; @@ -178,7 +177,7 @@ class EntityExporter $colIndex = 1; foreach ($columns as $column) { - $cellCoordinate = Coordinate::stringFromColumnIndex($colIndex) . $rowIndex; + $cellCoordinate = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex) . $rowIndex; $worksheet->setCellValue($cellCoordinate, $column); $colIndex++; } diff --git a/src/Services/ImportExportSystem/EntityImporter.php b/src/Services/ImportExportSystem/EntityImporter.php index 7b928d6c..a89be9dc 100644 --- a/src/Services/ImportExportSystem/EntityImporter.php +++ b/src/Services/ImportExportSystem/EntityImporter.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace App\Services\ImportExportSystem; -use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Parts\Category; @@ -420,14 +419,14 @@ class EntityImporter 'worksheet_title' => $worksheet->getTitle() ]); - $highestColumnIndex = Coordinate::columnIndexFromString($highestColumn); + $highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn); for ($row = 1; $row <= $highestRow; $row++) { $rowData = []; // Read all columns using numeric index for ($colIndex = 1; $colIndex <= $highestColumnIndex; $colIndex++) { - $col = Coordinate::stringFromColumnIndex($colIndex); + $col = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex); try { $cellValue = $worksheet->getCell("{$col}{$row}")->getCalculatedValue(); $rowData[] = $cellValue ?? ''; diff --git a/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php b/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php index 3db09de3..58e9e240 100644 --- a/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php +++ b/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace App\Services\InfoProviderSystem\DTOs; -use Doctrine\ORM\Exception\ORMException; use App\Entity\Parts\Part; use Doctrine\ORM\EntityManagerInterface; use Traversable; @@ -177,7 +176,7 @@ readonly class BulkSearchResponseDTO implements \ArrayAccess, \IteratorAggregate * @param array $data * @param EntityManagerInterface $entityManager * @return BulkSearchResponseDTO - * @throws ORMException + * @throws \Doctrine\ORM\Exception\ORMException */ public static function fromSerializableRepresentation(array $data, EntityManagerInterface $entityManager): BulkSearchResponseDTO { diff --git a/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php b/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php index c2291107..aa165bfe 100644 --- a/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php +++ b/src/Services/InfoProviderSystem/Providers/BuerklinProvider.php @@ -365,7 +365,7 @@ class BuerklinProvider implements BatchInfoProviderInterface, URLHandlerInfoProv * - prefers 'zoom' format, then 'product' format, then all others * * @param array|null $images - * @return FileDTO[] + * @return \App\Services\InfoProviderSystem\DTOs\FileDTO[] */ private function getProductImages(?array $images): array { diff --git a/src/Services/LabelSystem/SandboxedTwigFactory.php b/src/Services/LabelSystem/SandboxedTwigFactory.php index b4f1d9f6..d5e09fa5 100644 --- a/src/Services/LabelSystem/SandboxedTwigFactory.php +++ b/src/Services/LabelSystem/SandboxedTwigFactory.php @@ -70,14 +70,12 @@ use App\Twig\Sandbox\SandboxedLabelExtension; use App\Twig\TwigCoreExtension; use InvalidArgumentException; use Twig\Environment; -use Twig\Extension\AttributeExtension; use Twig\Extension\SandboxExtension; use Twig\Extra\Html\HtmlExtension; use Twig\Extra\Intl\IntlExtension; use Twig\Extra\Markdown\MarkdownExtension; use Twig\Extra\String\StringExtension; use Twig\Loader\ArrayLoader; -use Twig\RuntimeLoader\FactoryRuntimeLoader; use Twig\Sandbox\SecurityPolicyInterface; /** @@ -188,18 +186,13 @@ final class SandboxedTwigFactory $twig->addExtension(new StringExtension()); $twig->addExtension(new HtmlExtension()); + //Add Part-DB specific extension + $twig->addExtension($this->formatExtension); + $twig->addExtension($this->barcodeExtension); + $twig->addExtension($this->entityExtension); + $twig->addExtension($this->twigCoreExtension); $twig->addExtension($this->sandboxedLabelExtension); - //Our other extensions are using attributes, we need a bit more work to load them - $dynamicExtensions = [$this->formatExtension, $this->barcodeExtension, $this->entityExtension, $this->twigCoreExtension]; - $dynamicExtensionsMap = []; - - foreach ($dynamicExtensions as $extension) { - $twig->addExtension(new AttributeExtension($extension::class)); - $dynamicExtensionsMap[$extension::class] = static fn () => $extension; - } - $twig->addRuntimeLoader(new FactoryRuntimeLoader($dynamicExtensionsMap)); - return $twig; } diff --git a/src/Services/LogSystem/LogDiffFormatter.php b/src/Services/LogSystem/LogDiffFormatter.php index 1ac5a2f5..8b165d5a 100644 --- a/src/Services/LogSystem/LogDiffFormatter.php +++ b/src/Services/LogSystem/LogDiffFormatter.php @@ -32,7 +32,7 @@ class LogDiffFormatter * @param $old_data * @param $new_data */ - public function formatDiff(mixed $old_data, mixed $new_data): string + public function formatDiff($old_data, $new_data): string { if (is_string($old_data) && is_string($new_data)) { return $this->diffString($old_data, $new_data); diff --git a/src/Services/System/BackupManager.php b/src/Services/System/BackupManager.php index 4946bc24..9bdc7f71 100644 --- a/src/Services/System/BackupManager.php +++ b/src/Services/System/BackupManager.php @@ -22,8 +22,6 @@ declare(strict_types=1); namespace App\Services\System; -use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Shivas\VersioningBundle\Service\VersionManagerInterface; @@ -336,7 +334,7 @@ readonly class BackupManager $params = $connection->getParams(); $platform = $connection->getDatabasePlatform(); - if ($platform instanceof AbstractMySQLPlatform) { + if ($platform instanceof \Doctrine\DBAL\Platforms\AbstractMySQLPlatform) { // Use mysql command to import - need to use shell to handle input redirection $mysqlCmd = 'mysql'; if (isset($params['host'])) { @@ -363,7 +361,7 @@ readonly class BackupManager if (!$process->isSuccessful()) { throw new \RuntimeException('MySQL import failed: ' . $process->getErrorOutput()); } - } elseif ($platform instanceof PostgreSQLPlatform) { + } elseif ($platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform) { // Use psql command to import $psqlCmd = 'psql'; if (isset($params['host'])) { diff --git a/src/Twig/AttachmentExtension.php b/src/Twig/AttachmentExtension.php index 3d5ec611..9f81abe6 100644 --- a/src/Twig/AttachmentExtension.php +++ b/src/Twig/AttachmentExtension.php @@ -25,34 +25,22 @@ namespace App\Twig; use App\Entity\Attachments\Attachment; use App\Services\Attachments\AttachmentURLGenerator; use App\Services\Misc\FAIconGenerator; -use Twig\Attribute\AsTwigFunction; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -final readonly class AttachmentExtension +final class AttachmentExtension extends AbstractExtension { - public function __construct(private AttachmentURLGenerator $attachmentURLGenerator, private FAIconGenerator $FAIconGenerator) + public function __construct(protected AttachmentURLGenerator $attachmentURLGenerator, protected FAIconGenerator $FAIconGenerator) { } - /** - * Returns the URL of the thumbnail of the given attachment. Returns null if no thumbnail is available. - */ - #[AsTwigFunction("attachment_thumbnail")] - public function attachmentThumbnail(Attachment $attachment, string $filter_name = 'thumbnail_sm'): ?string + public function getFunctions(): array { - return $this->attachmentURLGenerator->getThumbnailURL($attachment, $filter_name); - } - - /** - * Return the font-awesome icon type for the given file extension. Returns "file" if no specific icon is available. - * Null is allowed for files withot extension - * @param string|null $extension - * @return string - */ - #[AsTwigFunction("ext_to_fa_icon")] - public function extToFAIcon(?string $extension): string - { - return $this->FAIconGenerator->fileExtensionToFAType($extension ?? ''); + return [ + /* Returns the URL to a thumbnail of the given attachment */ + new TwigFunction('attachment_thumbnail', fn(Attachment $attachment, string $filter_name = 'thumbnail_sm'): ?string => $this->attachmentURLGenerator->getThumbnailURL($attachment, $filter_name)), + /* Returns the font awesome icon class which is representing the given file extension (We allow null here for attachments without extension) */ + new TwigFunction('ext_to_fa_icon', fn(?string $extension): string => $this->FAIconGenerator->fileExtensionToFAType($extension ?? '')), + ]; } } diff --git a/src/Twig/BarcodeExtension.php b/src/Twig/BarcodeExtension.php index 25c0d78e..ae1973e3 100644 --- a/src/Twig/BarcodeExtension.php +++ b/src/Twig/BarcodeExtension.php @@ -23,14 +23,19 @@ declare(strict_types=1); namespace App\Twig; use Com\Tecnick\Barcode\Barcode; -use Twig\Attribute\AsTwigFunction; +use Twig\Extension\AbstractExtension; +use Twig\TwigFunction; -final class BarcodeExtension +final class BarcodeExtension extends AbstractExtension { - /** - * Generates a barcode in SVG format for the given content and type. - */ - #[AsTwigFunction('barcode_svg')] + public function getFunctions(): array + { + return [ + /* Generates a barcode with the given Type and Data and returns it as an SVG represenation */ + new TwigFunction('barcode_svg', fn(string $content, string $type = 'QRCODE'): string => $this->barcodeSVG($content, $type)), + ]; + } + public function barcodeSVG(string $content, string $type = 'QRCODE'): string { $barcodeFactory = new Barcode(); diff --git a/src/Twig/EntityExtension.php b/src/Twig/EntityExtension.php index bff21eb8..427a39b5 100644 --- a/src/Twig/EntityExtension.php +++ b/src/Twig/EntityExtension.php @@ -41,9 +41,6 @@ use App\Exceptions\EntityNotSupportedException; use App\Services\ElementTypeNameGenerator; use App\Services\EntityURLGenerator; use App\Services\Trees\TreeViewGenerator; -use Twig\Attribute\AsTwigFunction; -use Twig\Attribute\AsTwigTest; -use Twig\DeprecatedCallableInfo; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; use Twig\TwigTest; @@ -51,27 +48,61 @@ use Twig\TwigTest; /** * @see \App\Tests\Twig\EntityExtensionTest */ -final readonly class EntityExtension +final class EntityExtension extends AbstractExtension { - public function __construct(private EntityURLGenerator $entityURLGenerator, private TreeViewGenerator $treeBuilder, private ElementTypeNameGenerator $nameGenerator) + public function __construct(protected EntityURLGenerator $entityURLGenerator, protected TreeViewGenerator $treeBuilder, private readonly ElementTypeNameGenerator $nameGenerator) { } - /** - * Checks if the given variable is an entity (instance of AbstractDBElement). - */ - #[AsTwigTest("entity")] - public function entityTest(mixed $var): bool + public function getTests(): array { - return $var instanceof AbstractDBElement; + return [ + /* Checks if the given variable is an entitity (instance of AbstractDBElement) */ + new TwigTest('entity', static fn($var) => $var instanceof AbstractDBElement), + ]; } + public function getFunctions(): array + { + return [ + /* Returns a string representation of the given entity */ + new TwigFunction('entity_type', fn(object $entity): ?string => $this->getEntityType($entity)), + /* Returns the URL to the given entity */ + new TwigFunction('entity_url', fn(AbstractDBElement $entity, string $method = 'info'): string => $this->generateEntityURL($entity, $method)), + /* Returns the URL to the given entity in timetravel mode */ + new TwigFunction('timetravel_url', fn(AbstractDBElement $element, \DateTimeInterface $dateTime): ?string => $this->timeTravelURL($element, $dateTime)), + /* Generates a JSON array of the given tree */ + new TwigFunction('tree_data', fn(AbstractDBElement $element, string $type = 'newEdit'): string => $this->treeData($element, $type)), - /** - * Returns a string representation of the given entity - */ - #[AsTwigFunction("entity_type")] - public function entityType(object $entity): ?string + /* Gets a human readable label for the type of the given entity */ + new TwigFunction('entity_type_label', fn(object|string $entity): string => $this->nameGenerator->getLocalizedTypeLabel($entity)), + new TwigFunction('type_label', fn(object|string $entity): string => $this->nameGenerator->typeLabel($entity)), + new TwigFunction('type_label_p', fn(object|string $entity): string => $this->nameGenerator->typeLabelPlural($entity)), + ]; + } + + public function timeTravelURL(AbstractDBElement $element, \DateTimeInterface $dateTime): ?string + { + try { + return $this->entityURLGenerator->timeTravelURL($element, $dateTime); + } catch (EntityNotSupportedException) { + return null; + } + } + + public function treeData(AbstractDBElement $element, string $type = 'newEdit'): string + { + $tree = $this->treeBuilder->getTreeView($element::class, null, $type, $element); + + return json_encode($tree, JSON_THROW_ON_ERROR); + } + + public function generateEntityURL(AbstractDBElement $entity, string $method = 'info'): string + { + return $this->entityURLGenerator->getURL($entity, $method); + } + + public function getEntityType(object $entity): ?string { $map = [ Part::class => 'part', @@ -98,69 +129,4 @@ final readonly class EntityExtension return null; } - - /** - * Returns the URL for the given entity and method. E.g. for a Part and method "edit", it will return the URL to edit this part. - */ - #[AsTwigFunction("entity_url")] - public function entityURL(AbstractDBElement $entity, string $method = 'info'): string - { - return $this->entityURLGenerator->getURL($entity, $method); - } - - - /** - * Returns the URL for the given entity in timetravel mode. - */ - #[AsTwigFunction("timetravel_url")] - public function timeTravelURL(AbstractDBElement $element, \DateTimeInterface $dateTime): ?string - { - try { - return $this->entityURLGenerator->timeTravelURL($element, $dateTime); - } catch (EntityNotSupportedException) { - return null; - } - } - - /** - * Generates a tree data structure for the given element, which can be used to display a tree view of the element and its related entities. - * The type parameter can be used to specify the type of tree view (e.g. "newEdit" for the tree view in the new/edit pages). The returned data is a JSON string. - */ - #[AsTwigFunction("tree_data")] - public function treeData(AbstractDBElement $element, string $type = 'newEdit'): string - { - $tree = $this->treeBuilder->getTreeView($element::class, null, $type, $element); - - return json_encode($tree, JSON_THROW_ON_ERROR); - } - - /** - * Gets the localized type label for the given entity. E.g. for a Part, it will return "Part" in English and "Bauteil" in German. - * @deprecated Use the "type_label" function instead, which does the same but is more concise. - */ - #[AsTwigFunction("entity_type_label", deprecationInfo: new DeprecatedCallableInfo("Part-DB", "2", "Use the 'type_label' function instead."))] - public function entityTypeLabel(object|string $entity): string - { - return $this->nameGenerator->getLocalizedTypeLabel($entity); - } - - /** - * Gets the localized type label for the given entity. E.g. for a Part, it will return "Part" in English and "Bauteil" in German. - */ - #[AsTwigFunction("type_label")] - public function typeLabel(object|string $entity): string - { - return $this->nameGenerator->typeLabel($entity); - } - - /** - * Gets the localized plural type label for the given entity. E.g. for a Part, it will return "Parts" in English and "Bauteile" in German. - * @param object|string $entity - * @return string - */ - #[AsTwigFunction("type_label_p")] - public function typeLabelPlural(object|string $entity): string - { - return $this->nameGenerator->typeLabelPlural($entity); - } } diff --git a/src/Twig/FormatExtension.php b/src/Twig/FormatExtension.php index b91b7e11..46313aaf 100644 --- a/src/Twig/FormatExtension.php +++ b/src/Twig/FormatExtension.php @@ -29,28 +29,35 @@ use App\Services\Formatters\MarkdownParser; use App\Services\Formatters\MoneyFormatter; use App\Services\Formatters\SIFormatter; use Brick\Math\BigDecimal; -use Twig\Attribute\AsTwigFilter; +use Twig\Extension\AbstractExtension; +use Twig\TwigFilter; -final readonly class FormatExtension +final class FormatExtension extends AbstractExtension { - public function __construct(private MarkdownParser $markdownParser, private MoneyFormatter $moneyFormatter, private SIFormatter $siformatter, private AmountFormatter $amountFormatter) + public function __construct(protected MarkdownParser $markdownParser, protected MoneyFormatter $moneyFormatter, protected SIFormatter $siformatter, protected AmountFormatter $amountFormatter) { } - /** - * Mark the given text as markdown, which will be rendered in the browser - */ - #[AsTwigFilter("format_markdown", isSafe: ['html'], preEscape: 'html')] - public function formatMarkdown(string $markdown, bool $inline_mode = false): string + public function getFilters(): array { - return $this->markdownParser->markForRendering($markdown, $inline_mode); + return [ + /* Mark the given text as markdown, which will be rendered in the browser */ + new TwigFilter('format_markdown', fn(string $markdown, bool $inline_mode = false): string => $this->markdownParser->markForRendering($markdown, $inline_mode), [ + 'pre_escape' => 'html', + 'is_safe' => ['html'], + ]), + /* Format the given amount as money, using a given currency */ + new TwigFilter('format_money', fn($amount, ?Currency $currency = null, int $decimals = 5): string => $this->formatCurrency($amount, $currency, $decimals)), + /* Format the given number using SI prefixes and the given unit (string) */ + new TwigFilter('format_si', fn($value, $unit, $decimals = 2, bool $show_all_digits = false): string => $this->siFormat($value, $unit, $decimals, $show_all_digits)), + /** Format the given amount using the given MeasurementUnit */ + new TwigFilter('format_amount', fn($value, ?MeasurementUnit $unit, array $options = []): string => $this->amountFormat($value, $unit, $options)), + /** Format the given number of bytes as human-readable number */ + new TwigFilter('format_bytes', fn(int $bytes, int $precision = 2): string => $this->formatBytes($bytes, $precision)), + ]; } - /** - * Format the given amount as money, using a given currency - */ - #[AsTwigFilter("format_money")] - public function formatMoney(BigDecimal|float|string $amount, ?Currency $currency = null, int $decimals = 5): string + public function formatCurrency($amount, ?Currency $currency = null, int $decimals = 5): string { if ($amount instanceof BigDecimal) { $amount = (string) $amount; @@ -59,22 +66,19 @@ final readonly class FormatExtension return $this->moneyFormatter->format($amount, $currency, $decimals); } - /** - * Format the given number using SI prefixes and the given unit (string) - */ - #[AsTwigFilter("format_si")] - public function siFormat(float $value, string $unit, int $decimals = 2, bool $show_all_digits = false): string + public function siFormat($value, $unit, $decimals = 2, bool $show_all_digits = false): string { return $this->siformatter->format($value, $unit, $decimals); } - #[AsTwigFilter("format_amount")] - public function amountFormat(float|int|string $value, ?MeasurementUnit $unit, array $options = []): string + public function amountFormat($value, ?MeasurementUnit $unit, array $options = []): string { return $this->amountFormatter->format($value, $unit, $options); } - #[AsTwigFilter("format_bytes")] + /** + * @param $bytes + */ public function formatBytes(int $bytes, int $precision = 2): string { $size = ['B','kB','MB','GB','TB','PB','EB','ZB','YB']; diff --git a/src/Twig/InfoProviderExtension.php b/src/Twig/InfoProviderExtension.php index 54dbf93a..a963b778 100644 --- a/src/Twig/InfoProviderExtension.php +++ b/src/Twig/InfoProviderExtension.php @@ -23,25 +23,31 @@ declare(strict_types=1); namespace App\Twig; -use Twig\Attribute\AsTwigFunction; use App\Services\InfoProviderSystem\ProviderRegistry; use App\Services\InfoProviderSystem\Providers\InfoProviderInterface; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -final readonly class InfoProviderExtension +class InfoProviderExtension extends AbstractExtension { public function __construct( - private ProviderRegistry $providerRegistry + private readonly ProviderRegistry $providerRegistry ) {} + public function getFunctions(): array + { + return [ + new TwigFunction('info_provider', $this->getInfoProvider(...)), + new TwigFunction('info_provider_label', $this->getInfoProviderName(...)) + ]; + } + /** * Gets the info provider with the given key. Returns null, if the provider does not exist. * @param string $key * @return InfoProviderInterface|null */ - #[AsTwigFunction(name: 'info_provider')] - public function getInfoProvider(string $key): ?InfoProviderInterface + private function getInfoProvider(string $key): ?InfoProviderInterface { try { return $this->providerRegistry->getProviderByKey($key); @@ -55,8 +61,7 @@ final readonly class InfoProviderExtension * @param string $key * @return string|null */ - #[AsTwigFunction(name: 'info_provider_label')] - public function getInfoProviderName(string $key): ?string + private function getInfoProviderName(string $key): ?string { try { return $this->providerRegistry->getProviderByKey($key)->getProviderInfo()['name']; @@ -64,4 +69,4 @@ final readonly class InfoProviderExtension return null; } } -} +} \ No newline at end of file diff --git a/src/Twig/LogExtension.php b/src/Twig/LogExtension.php index 738a24c2..34dad988 100644 --- a/src/Twig/LogExtension.php +++ b/src/Twig/LogExtension.php @@ -25,26 +25,21 @@ namespace App\Twig; use App\Entity\LogSystem\AbstractLogEntry; use App\Services\LogSystem\LogDataFormatter; use App\Services\LogSystem\LogDiffFormatter; -use Twig\Attribute\AsTwigFunction; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -final readonly class LogExtension +final class LogExtension extends AbstractExtension { - public function __construct(private LogDataFormatter $logDataFormatter, private LogDiffFormatter $logDiffFormatter) + public function __construct(private readonly LogDataFormatter $logDataFormatter, private readonly LogDiffFormatter $logDiffFormatter) { } - #[AsTwigFunction(name: 'format_log_data', isSafe: ['html'])] - public function formatLogData(mixed $data, AbstractLogEntry $logEntry, string $fieldName): string + public function getFunctions(): array { - return $this->logDataFormatter->formatData($data, $logEntry, $fieldName); - } - - #[AsTwigFunction(name: 'format_log_diff', isSafe: ['html'])] - public function formatLogDiff(mixed $old_data, mixed $new_data): string - { - return $this->logDiffFormatter->formatDiff($old_data, $new_data); + return [ + new TwigFunction('format_log_data', fn($data, AbstractLogEntry $logEntry, string $fieldName): string => $this->logDataFormatter->formatData($data, $logEntry, $fieldName), ['is_safe' => ['html']]), + new TwigFunction('format_log_diff', fn($old_data, $new_data): string => $this->logDiffFormatter->formatDiff($old_data, $new_data), ['is_safe' => ['html']]), + ]; } } diff --git a/src/Twig/MiscExtension.php b/src/Twig/MiscExtension.php index 390ad084..8b6ebc68 100644 --- a/src/Twig/MiscExtension.php +++ b/src/Twig/MiscExtension.php @@ -22,7 +22,6 @@ declare(strict_types=1); */ namespace App\Twig; -use Twig\Attribute\AsTwigFunction; use App\Settings\SettingsIcon; use Symfony\Component\HttpFoundation\Request; use App\Services\LogSystem\EventCommentType; @@ -32,14 +31,23 @@ use Twig\TwigFunction; use App\Services\LogSystem\EventCommentNeededHelper; use Twig\Extension\AbstractExtension; -final readonly class MiscExtension +final class MiscExtension extends AbstractExtension { - public function __construct(private EventCommentNeededHelper $eventCommentNeededHelper) + public function __construct(private readonly EventCommentNeededHelper $eventCommentNeededHelper) { } - #[AsTwigFunction(name: 'event_comment_needed')] - public function evenCommentNeeded(string|EventCommentType $operation_type): bool + public function getFunctions(): array + { + return [ + new TwigFunction('event_comment_needed', $this->evenCommentNeeded(...)), + + new TwigFunction('settings_icon', $this->settingsIcon(...)), + new TwigFunction('uri_without_host', $this->uri_without_host(...)) + ]; + } + + private function evenCommentNeeded(string|EventCommentType $operation_type): bool { if (is_string($operation_type)) { $operation_type = EventCommentType::from($operation_type); @@ -55,8 +63,7 @@ final readonly class MiscExtension * @return string|null * @throws \ReflectionException */ - #[AsTwigFunction(name: 'settings_icon')] - public function settingsIcon(string|object $objectOrClass): ?string + private function settingsIcon(string|object $objectOrClass): ?string { //If the given object is a proxy, then get the real object if (is_a($objectOrClass, SettingsProxyInterface::class)) { @@ -75,7 +82,6 @@ final readonly class MiscExtension * @param Request $request * @return string */ - #[AsTwigFunction(name: 'uri_without_host')] public function uri_without_host(Request $request): string { if (null !== $qs = $request->getQueryString()) { diff --git a/src/Twig/TwigCoreExtension.php b/src/Twig/TwigCoreExtension.php index ceb4ce82..7b2b58f8 100644 --- a/src/Twig/TwigCoreExtension.php +++ b/src/Twig/TwigCoreExtension.php @@ -22,11 +22,7 @@ declare(strict_types=1); */ namespace App\Twig; -use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -use Twig\Attribute\AsTwigFilter; -use Twig\Attribute\AsTwigFunction; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; -use Twig\Attribute\AsTwigTest; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; use Twig\TwigFunction; @@ -36,54 +32,58 @@ use Twig\TwigTest; * The functionalities here extend the Twig with some core functions, which are independently of Part-DB. * @see \App\Tests\Twig\TwigCoreExtensionTest */ -final readonly class TwigCoreExtension +final class TwigCoreExtension extends AbstractExtension { - private NormalizerInterface $objectNormalizer; + private readonly ObjectNormalizer $objectNormalizer; public function __construct() { $this->objectNormalizer = new ObjectNormalizer(); } - /** - * Checks if the given variable is an instance of the given class/interface/enum. E.g. `x is instanceof('App\Entity\Parts\Part')` - * @param mixed $var - * @param string $instance - * @return bool - */ - #[AsTwigTest("instanceof")] - public function testInstanceOf(mixed $var, string $instance): bool + public function getFunctions(): array { - if (!class_exists($instance) && !interface_exists($instance) && !enum_exists($instance)) { - throw new \InvalidArgumentException(sprintf('The given class/interface/enum "%s" does not exist!', $instance)); + return [ + /* Returns the enum cases as values */ + new TwigFunction('enum_cases', $this->getEnumCases(...)), + ]; + } + + public function getTests(): array + { + return [ + /* + * Checks if a given variable is an instance of a given class. E.g. ` x is instanceof('App\Entity\Parts\Part')` + */ + new TwigTest('instanceof', static fn($var, $instance) => $var instanceof $instance), + /* Checks if a given variable is an object. E.g. `x is object` */ + new TwigTest('object', static fn($var): bool => is_object($var)), + new TwigTest('enum', fn($var) => $var instanceof \UnitEnum), + ]; + } + + /** + * @param string $enum_class + * @phpstan-param class-string $enum_class + */ + public function getEnumCases(string $enum_class): array + { + if (!enum_exists($enum_class)) { + throw new \InvalidArgumentException(sprintf('The given class "%s" is not an enum!', $enum_class)); } - return $var instanceof $instance; + /** @noinspection PhpUndefinedMethodInspection */ + return ($enum_class)::cases(); } - /** - * Checks if the given variable is an object. This can be used to check if a variable is an object, without knowing the exact class of the object. E.g. `x is object` - * @param mixed $var - * @return bool - */ - #[AsTwigTest("object")] - public function testObject(mixed $var): bool + public function getFilters(): array { - return is_object($var); + return [ + /* Converts the given object to an array representation of the public/accessible properties */ + new TwigFilter('to_array', fn($object) => $this->toArray($object)), + ]; } - /** - * Checks if the given variable is an enum (instance of UnitEnum). This can be used to check if a variable is an enum, without knowing the exact class of the enum. E.g. `x is enum` - * @param mixed $var - * @return bool - */ - #[AsTwigTest("enum")] - public function testEnum(mixed $var): bool - { - return $var instanceof \UnitEnum; - } - - #[AsTwigFilter('to_array')] public function toArray(object|array $object): array { //If it is already an array, we can just return it diff --git a/src/Twig/UpdateExtension.php b/src/Twig/UpdateExtension.php index 7ec7897b..ee3bb16c 100644 --- a/src/Twig/UpdateExtension.php +++ b/src/Twig/UpdateExtension.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace App\Twig; -use Twig\Attribute\AsTwigFunction; use App\Services\System\UpdateAvailableFacade; use Symfony\Bundle\SecurityBundle\Security; use Twig\Extension\AbstractExtension; @@ -32,18 +31,26 @@ use Twig\TwigFunction; /** * Twig extension for update-related functions. */ -final readonly class UpdateExtension +final class UpdateExtension extends AbstractExtension { - public function __construct(private UpdateAvailableFacade $updateAvailableManager, - private Security $security) + public function __construct(private readonly UpdateAvailableFacade $updateAvailableManager, + private readonly Security $security) { } + public function getFunctions(): array + { + return [ + new TwigFunction('is_update_available', $this->isUpdateAvailable(...)), + new TwigFunction('get_latest_version', $this->getLatestVersion(...)), + new TwigFunction('get_latest_version_url', $this->getLatestVersionUrl(...)), + ]; + } + /** * Check if an update is available and the user has permission to see it. */ - #[AsTwigFunction(name: 'is_update_available')] public function isUpdateAvailable(): bool { // Only show to users with the show_updates permission @@ -57,7 +64,6 @@ final readonly class UpdateExtension /** * Get the latest available version string. */ - #[AsTwigFunction(name: 'get_latest_version')] public function getLatestVersion(): string { return $this->updateAvailableManager->getLatestVersionString(); @@ -66,7 +72,6 @@ final readonly class UpdateExtension /** * Get the URL to the latest version release page. */ - #[AsTwigFunction(name: 'get_latest_version_url')] public function getLatestVersionUrl(): string { return $this->updateAvailableManager->getLatestVersionUrl(); diff --git a/src/Twig/UserExtension.php b/src/Twig/UserExtension.php index 81ff0857..5045257a 100644 --- a/src/Twig/UserExtension.php +++ b/src/Twig/UserExtension.php @@ -41,24 +41,51 @@ declare(strict_types=1); namespace App\Twig; -use Twig\Attribute\AsTwigFilter; -use Twig\Attribute\AsTwigFunction; +use App\Entity\Base\AbstractDBElement; use App\Entity\UserSystem\User; +use App\Entity\LogSystem\AbstractLogEntry; +use App\Repository\LogEntryRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken; use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Twig\Extension\AbstractExtension; +use Twig\TwigFilter; +use Twig\TwigFunction; /** * @see \App\Tests\Twig\UserExtensionTest */ -final readonly class UserExtension +final class UserExtension extends AbstractExtension { + private readonly LogEntryRepository $repo; - public function __construct( - private Security $security, - private UrlGeneratorInterface $urlGenerator) + public function __construct(EntityManagerInterface $em, + private readonly Security $security, + private readonly UrlGeneratorInterface $urlGenerator) { + $this->repo = $em->getRepository(AbstractLogEntry::class); + } + + public function getFilters(): array + { + return [ + new TwigFilter('remove_locale_from_path', fn(string $path): string => $this->removeLocaleFromPath($path)), + ]; + } + + public function getFunctions(): array + { + return [ + /* Returns the user which has edited the given entity the last time. */ + new TwigFunction('last_editing_user', fn(AbstractDBElement $element): ?User => $this->repo->getLastEditingUser($element)), + /* Returns the user which has created the given entity. */ + new TwigFunction('creating_user', fn(AbstractDBElement $element): ?User => $this->repo->getCreatingUser($element)), + new TwigFunction('impersonator_user', $this->getImpersonatorUser(...)), + new TwigFunction('impersonation_active', $this->isImpersonationActive(...)), + new TwigFunction('impersonation_path', $this->getImpersonationPath(...)), + ]; } /** @@ -66,7 +93,6 @@ final readonly class UserExtension * If the current user is not impersonated, null is returned. * @return User|null */ - #[AsTwigFunction(name: 'impersonator_user')] public function getImpersonatorUser(): ?User { $token = $this->security->getToken(); @@ -81,13 +107,11 @@ final readonly class UserExtension return null; } - #[AsTwigFunction(name: 'impersonation_active')] public function isImpersonationActive(): bool { return $this->security->isGranted('IS_IMPERSONATOR'); } - #[AsTwigFunction(name: 'impersonation_path')] public function getImpersonationPath(User $user, string $route_name = 'homepage'): string { if (! $this->security->isGranted('CAN_SWITCH_USER', $user)) { @@ -100,7 +124,6 @@ final readonly class UserExtension /** * This function/filter generates a path. */ - #[AsTwigFilter(name: 'remove_locale_from_path')] public function removeLocaleFromPath(string $path): string { //Ensure the path has the correct format diff --git a/src/Twig/UserRepoExtension.php b/src/Twig/UserRepoExtension.php deleted file mode 100644 index 1dcc6706..00000000 --- a/src/Twig/UserRepoExtension.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -declare(strict_types=1); - - -namespace App\Twig; - -use App\Entity\Base\AbstractDBElement; -use App\Entity\LogSystem\AbstractLogEntry; -use App\Entity\UserSystem\User; -use App\Repository\LogEntryRepository; -use Doctrine\ORM\EntityManagerInterface; -use Twig\Attribute\AsTwigFunction; - -final readonly class UserRepoExtension -{ - - public function __construct(private EntityManagerInterface $entityManager) - { - } - - /** - * Returns the user which has edited the given entity the last time. - */ - #[AsTwigFunction('creating_user')] - public function creatingUser(AbstractDBElement $element): ?User - { - return $this->entityManager->getRepository(AbstractLogEntry::class)->getCreatingUser($element); - } - - /** - * Returns the user which has edited the given entity the last time. - */ - #[AsTwigFunction('last_editing_user')] - public function lastEditingUser(AbstractDBElement $element): ?User - { - return $this->entityManager->getRepository(AbstractLogEntry::class)->getLastEditingUser($element); - } -} diff --git a/src/Validator/Constraints/UniquePartIpnConstraint.php b/src/Validator/Constraints/UniquePartIpnConstraint.php index 652f2bcd..ca32f9ef 100644 --- a/src/Validator/Constraints/UniquePartIpnConstraint.php +++ b/src/Validator/Constraints/UniquePartIpnConstraint.php @@ -1,7 +1,5 @@ - {% if entity is instanceof("App\\Entity\\Parts\\StorageLocation") %} + {% if entity is instanceof("App\\Entity\\Parts\\Storelocation") %} {{ dropdown.profile_dropdown('storelocation', entity.id, true, 'btn-secondary w-100 mt-2') }} {% endif %} @@ -136,4 +136,4 @@ {% if filterForm is defined %} {% include "parts/lists/_filter.html.twig" %} {% endif %} - + \ No newline at end of file diff --git a/tests/API/APIDocsAvailabilityTest.php b/tests/API/APIDocsAvailabilityTest.php index a7bba3d6..b7caa873 100644 --- a/tests/API/APIDocsAvailabilityTest.php +++ b/tests/API/APIDocsAvailabilityTest.php @@ -28,7 +28,7 @@ use App\Entity\UserSystem\User; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class APIDocsAvailabilityTest extends WebTestCase +class APIDocsAvailabilityTest extends WebTestCase { #[DataProvider('urlProvider')] public function testDocAvailabilityForLoggedInUser(string $url): void diff --git a/tests/API/APITokenAuthenticationTest.php b/tests/API/APITokenAuthenticationTest.php index 803a1819..a78b0594 100644 --- a/tests/API/APITokenAuthenticationTest.php +++ b/tests/API/APITokenAuthenticationTest.php @@ -27,7 +27,7 @@ use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; use App\DataFixtures\APITokenFixtures; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use ApiPlatform\Symfony\Bundle\Test\Client; -final class APITokenAuthenticationTest extends ApiTestCase +class APITokenAuthenticationTest extends ApiTestCase { public function testUnauthenticated(): void { diff --git a/tests/API/Endpoints/ApiTokenEnpointTest.php b/tests/API/Endpoints/ApiTokenEnpointTest.php index f21716bd..99340182 100644 --- a/tests/API/Endpoints/ApiTokenEnpointTest.php +++ b/tests/API/Endpoints/ApiTokenEnpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\AuthenticatedApiTestCase; -final class ApiTokenEnpointTest extends AuthenticatedApiTestCase +class ApiTokenEnpointTest extends AuthenticatedApiTestCase { public function testGetCurrentToken(): void { diff --git a/tests/API/Endpoints/AttachmentTypeEndpointTest.php b/tests/API/Endpoints/AttachmentTypeEndpointTest.php index fb5770d5..f90f3d94 100644 --- a/tests/API/Endpoints/AttachmentTypeEndpointTest.php +++ b/tests/API/Endpoints/AttachmentTypeEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class AttachmentTypeEndpointTest extends CrudEndpointTestCase +class AttachmentTypeEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/AttachmentsEndpointTest.php b/tests/API/Endpoints/AttachmentsEndpointTest.php index 999b7ad3..8f4d7e77 100644 --- a/tests/API/Endpoints/AttachmentsEndpointTest.php +++ b/tests/API/Endpoints/AttachmentsEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\AuthenticatedApiTestCase; -final class AttachmentsEndpointTest extends AuthenticatedApiTestCase +class AttachmentsEndpointTest extends AuthenticatedApiTestCase { public function testGetCollection(): void { diff --git a/tests/API/Endpoints/CategoryEndpointTest.php b/tests/API/Endpoints/CategoryEndpointTest.php index 5f54d1dd..68f4fd2d 100644 --- a/tests/API/Endpoints/CategoryEndpointTest.php +++ b/tests/API/Endpoints/CategoryEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class CategoryEndpointTest extends CrudEndpointTestCase +class CategoryEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/CurrencyEndpointTest.php b/tests/API/Endpoints/CurrencyEndpointTest.php index a9f36633..a463daeb 100644 --- a/tests/API/Endpoints/CurrencyEndpointTest.php +++ b/tests/API/Endpoints/CurrencyEndpointTest.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Tests\API\Endpoints; -final class CurrencyEndpointTest extends CrudEndpointTestCase +class CurrencyEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/FootprintsEndpointTest.php b/tests/API/Endpoints/FootprintsEndpointTest.php index fd6374f9..f3f359a2 100644 --- a/tests/API/Endpoints/FootprintsEndpointTest.php +++ b/tests/API/Endpoints/FootprintsEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class FootprintsEndpointTest extends CrudEndpointTestCase +class FootprintsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/InfoEndpointTest.php b/tests/API/Endpoints/InfoEndpointTest.php index 6e996c0c..09f02e8a 100644 --- a/tests/API/Endpoints/InfoEndpointTest.php +++ b/tests/API/Endpoints/InfoEndpointTest.php @@ -25,7 +25,7 @@ namespace API\Endpoints; use App\Tests\API\AuthenticatedApiTestCase; -final class InfoEndpointTest extends AuthenticatedApiTestCase +class InfoEndpointTest extends AuthenticatedApiTestCase { public function testGetInfo(): void { diff --git a/tests/API/Endpoints/ManufacturersEndpointTest.php b/tests/API/Endpoints/ManufacturersEndpointTest.php index 80447c93..482ec98d 100644 --- a/tests/API/Endpoints/ManufacturersEndpointTest.php +++ b/tests/API/Endpoints/ManufacturersEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class ManufacturersEndpointTest extends CrudEndpointTestCase +class ManufacturersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/MeasurementUnitsEndpointTest.php b/tests/API/Endpoints/MeasurementUnitsEndpointTest.php index d659fb1c..db7341db 100644 --- a/tests/API/Endpoints/MeasurementUnitsEndpointTest.php +++ b/tests/API/Endpoints/MeasurementUnitsEndpointTest.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Tests\API\Endpoints; -final class MeasurementUnitsEndpointTest extends CrudEndpointTestCase +class MeasurementUnitsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/OrderdetailsEndpointTest.php b/tests/API/Endpoints/OrderdetailsEndpointTest.php index d7d132d9..92823103 100644 --- a/tests/API/Endpoints/OrderdetailsEndpointTest.php +++ b/tests/API/Endpoints/OrderdetailsEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class OrderdetailsEndpointTest extends CrudEndpointTestCase +class OrderdetailsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/ParametersEndpointTest.php b/tests/API/Endpoints/ParametersEndpointTest.php index 323fc7b8..733df59a 100644 --- a/tests/API/Endpoints/ParametersEndpointTest.php +++ b/tests/API/Endpoints/ParametersEndpointTest.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Tests\API\Endpoints; -final class ParametersEndpointTest extends CrudEndpointTestCase +class ParametersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartAssociationsEndpointTest.php b/tests/API/Endpoints/PartAssociationsEndpointTest.php index 7ac81ff6..62408dbb 100644 --- a/tests/API/Endpoints/PartAssociationsEndpointTest.php +++ b/tests/API/Endpoints/PartAssociationsEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class PartAssociationsEndpointTest extends CrudEndpointTestCase +class PartAssociationsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartCustomStateEndpointTest.php b/tests/API/Endpoints/PartCustomStateEndpointTest.php index 8d1253f3..ac353d9c 100644 --- a/tests/API/Endpoints/PartCustomStateEndpointTest.php +++ b/tests/API/Endpoints/PartCustomStateEndpointTest.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Tests\API\Endpoints; -final class PartCustomStateEndpointTest extends CrudEndpointTestCase +class PartCustomStateEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartEndpointTest.php b/tests/API/Endpoints/PartEndpointTest.php index 8d66d362..9406fc78 100644 --- a/tests/API/Endpoints/PartEndpointTest.php +++ b/tests/API/Endpoints/PartEndpointTest.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Tests\API\Endpoints; -final class PartEndpointTest extends CrudEndpointTestCase +class PartEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartLotsEndpointTest.php b/tests/API/Endpoints/PartLotsEndpointTest.php index 70f1f9ab..38aa6b18 100644 --- a/tests/API/Endpoints/PartLotsEndpointTest.php +++ b/tests/API/Endpoints/PartLotsEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class PartLotsEndpointTest extends CrudEndpointTestCase +class PartLotsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PricedetailsEndpointTest.php b/tests/API/Endpoints/PricedetailsEndpointTest.php index 5661c0c7..8895365f 100644 --- a/tests/API/Endpoints/PricedetailsEndpointTest.php +++ b/tests/API/Endpoints/PricedetailsEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class PricedetailsEndpointTest extends CrudEndpointTestCase +class PricedetailsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/ProjectBOMEntriesEndpointTest.php b/tests/API/Endpoints/ProjectBOMEntriesEndpointTest.php index 10dbf747..cafb57dc 100644 --- a/tests/API/Endpoints/ProjectBOMEntriesEndpointTest.php +++ b/tests/API/Endpoints/ProjectBOMEntriesEndpointTest.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Tests\API\Endpoints; -final class ProjectBOMEntriesEndpointTest extends CrudEndpointTestCase +class ProjectBOMEntriesEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/ProjectsEndpointTest.php b/tests/API/Endpoints/ProjectsEndpointTest.php index ea9cc6b4..9daf584a 100644 --- a/tests/API/Endpoints/ProjectsEndpointTest.php +++ b/tests/API/Endpoints/ProjectsEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class ProjectsEndpointTest extends CrudEndpointTestCase +class ProjectsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/StorageLocationsEndpointTest.php b/tests/API/Endpoints/StorageLocationsEndpointTest.php index 11947e71..8d9641c4 100644 --- a/tests/API/Endpoints/StorageLocationsEndpointTest.php +++ b/tests/API/Endpoints/StorageLocationsEndpointTest.php @@ -25,7 +25,7 @@ namespace API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class StorageLocationsEndpointTest extends CrudEndpointTestCase +class StorageLocationsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/SuppliersEndpointTest.php b/tests/API/Endpoints/SuppliersEndpointTest.php index bbb64e90..1941f849 100644 --- a/tests/API/Endpoints/SuppliersEndpointTest.php +++ b/tests/API/Endpoints/SuppliersEndpointTest.php @@ -25,7 +25,7 @@ namespace App\Tests\API\Endpoints; use App\Tests\API\Endpoints\CrudEndpointTestCase; -final class SuppliersEndpointTest extends CrudEndpointTestCase +class SuppliersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/UsersEndpointTest.php b/tests/API/Endpoints/UsersEndpointTest.php index e6e18930..0f075a7c 100644 --- a/tests/API/Endpoints/UsersEndpointTest.php +++ b/tests/API/Endpoints/UsersEndpointTest.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Tests\API\Endpoints; -final class UsersEndpointTest extends CrudEndpointTestCase +class UsersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/ApplicationAvailabilityFunctionalTest.php b/tests/ApplicationAvailabilityFunctionalTest.php index c7449411..d5bced49 100644 --- a/tests/ApplicationAvailabilityFunctionalTest.php +++ b/tests/ApplicationAvailabilityFunctionalTest.php @@ -32,7 +32,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ #[Group('DB')] #[Group('slow')] -final class ApplicationAvailabilityFunctionalTest extends WebTestCase +class ApplicationAvailabilityFunctionalTest extends WebTestCase { #[DataProvider('urlProvider')] public function testPageIsSuccessful(string $url): void diff --git a/tests/Controller/AdminPages/AttachmentTypeController.php b/tests/Controller/AdminPages/AttachmentTypeController.php index 90e6583d..599a6f69 100644 --- a/tests/Controller/AdminPages/AttachmentTypeController.php +++ b/tests/Controller/AdminPages/AttachmentTypeController.php @@ -27,7 +27,7 @@ use App\Entity\Attachments\AttachmentType; #[Group('slow')] #[Group('DB')] -final class AttachmentTypeController extends AbstractAdminController +class AttachmentTypeController extends AbstractAdminController { protected static string $base_path = '/en/attachment_type'; protected static string $entity_class = AttachmentType::class; diff --git a/tests/Controller/AdminPages/CategoryController.php b/tests/Controller/AdminPages/CategoryController.php index 5d8396e7..c1bac093 100644 --- a/tests/Controller/AdminPages/CategoryController.php +++ b/tests/Controller/AdminPages/CategoryController.php @@ -27,7 +27,7 @@ use App\Entity\Parts\Category; #[Group('slow')] #[Group('DB')] -final class CategoryController extends AbstractAdminController +class CategoryController extends AbstractAdminController { protected static string $base_path = '/en/category'; protected static string $entity_class = Category::class; diff --git a/tests/Controller/AdminPages/CurrencyController.php b/tests/Controller/AdminPages/CurrencyController.php index 4ebd82e2..21f94a29 100644 --- a/tests/Controller/AdminPages/CurrencyController.php +++ b/tests/Controller/AdminPages/CurrencyController.php @@ -28,7 +28,7 @@ use App\Entity\Parts\Manufacturer; #[Group('slow')] #[Group('DB')] -final class CurrencyController extends AbstractAdminController +class CurrencyController extends AbstractAdminController { protected static string $base_path = '/en/currency'; protected static string $entity_class = Currency::class; diff --git a/tests/Controller/AdminPages/FootprintController.php b/tests/Controller/AdminPages/FootprintController.php index 2643d3f1..7d617ba8 100644 --- a/tests/Controller/AdminPages/FootprintController.php +++ b/tests/Controller/AdminPages/FootprintController.php @@ -27,7 +27,7 @@ use App\Entity\Parts\Footprint; #[Group('slow')] #[Group('DB')] -final class FootprintController extends AbstractAdminController +class FootprintController extends AbstractAdminController { protected static string $base_path = '/en/footprint'; protected static string $entity_class = Footprint::class; diff --git a/tests/Controller/AdminPages/LabelProfileController.php b/tests/Controller/AdminPages/LabelProfileController.php index d407701a..838d872e 100644 --- a/tests/Controller/AdminPages/LabelProfileController.php +++ b/tests/Controller/AdminPages/LabelProfileController.php @@ -46,7 +46,7 @@ use PHPUnit\Framework\Attributes\Group; use App\Entity\LabelSystem\LabelProfile; use Symfony\Component\Security\Core\Exception\AccessDeniedException; -final class LabelProfileController extends AbstractAdminController +class LabelProfileController extends AbstractAdminController { protected static string $base_path = '/en/label_profile'; protected static string $entity_class = LabelProfile::class; diff --git a/tests/Controller/AdminPages/ManufacturerController.php b/tests/Controller/AdminPages/ManufacturerController.php index 2a5ed386..c2666f72 100644 --- a/tests/Controller/AdminPages/ManufacturerController.php +++ b/tests/Controller/AdminPages/ManufacturerController.php @@ -27,7 +27,7 @@ use App\Entity\Parts\Manufacturer; #[Group('slow')] #[Group('DB')] -final class ManufacturerController extends AbstractAdminController +class ManufacturerController extends AbstractAdminController { protected static string $base_path = '/en/manufacturer'; protected static string $entity_class = Manufacturer::class; diff --git a/tests/Controller/AdminPages/MeasurementUnitController.php b/tests/Controller/AdminPages/MeasurementUnitController.php index c15d4af4..351f4e51 100644 --- a/tests/Controller/AdminPages/MeasurementUnitController.php +++ b/tests/Controller/AdminPages/MeasurementUnitController.php @@ -27,7 +27,7 @@ use App\Entity\Parts\MeasurementUnit; #[Group('slow')] #[Group('DB')] -final class MeasurementUnitController extends AbstractAdminController +class MeasurementUnitController extends AbstractAdminController { protected static string $base_path = '/en/measurement_unit'; protected static string $entity_class = MeasurementUnit::class; diff --git a/tests/Controller/AdminPages/PartCustomStateControllerTest.php b/tests/Controller/AdminPages/PartCustomStateControllerTest.php index 77d1127c..3e87dfe2 100644 --- a/tests/Controller/AdminPages/PartCustomStateControllerTest.php +++ b/tests/Controller/AdminPages/PartCustomStateControllerTest.php @@ -27,7 +27,7 @@ use PHPUnit\Framework\Attributes\Group; #[Group('slow')] #[Group('DB')] -final class PartCustomStateControllerTest extends AbstractAdminController +class PartCustomStateControllerTest extends AbstractAdminController { protected static string $base_path = '/en/part_custom_state'; protected static string $entity_class = PartCustomState::class; diff --git a/tests/Controller/AdminPages/ProjectController.php b/tests/Controller/AdminPages/ProjectController.php index d7bec069..1de4bf52 100644 --- a/tests/Controller/AdminPages/ProjectController.php +++ b/tests/Controller/AdminPages/ProjectController.php @@ -28,7 +28,7 @@ use App\Entity\ProjectSystem\Project; #[Group('slow')] #[Group('DB')] -final class ProjectController extends AbstractAdminController +class ProjectController extends AbstractAdminController { protected static string $base_path = '/en/project'; protected static string $entity_class = Project::class; diff --git a/tests/Controller/AdminPages/StorelocationController.php b/tests/Controller/AdminPages/StorelocationController.php index f19a5f6a..fee06c67 100644 --- a/tests/Controller/AdminPages/StorelocationController.php +++ b/tests/Controller/AdminPages/StorelocationController.php @@ -27,7 +27,7 @@ use App\Entity\Parts\StorageLocation; #[Group('slow')] #[Group('DB')] -final class StorelocationController extends AbstractAdminController +class StorelocationController extends AbstractAdminController { protected static string $base_path = '/en/store_location'; protected static string $entity_class = StorageLocation::class; diff --git a/tests/Controller/AdminPages/SupplierController.php b/tests/Controller/AdminPages/SupplierController.php index 1e1d720a..3549eb4b 100644 --- a/tests/Controller/AdminPages/SupplierController.php +++ b/tests/Controller/AdminPages/SupplierController.php @@ -27,7 +27,7 @@ use App\Entity\Parts\Supplier; #[Group('slow')] #[Group('DB')] -final class SupplierController extends AbstractAdminController +class SupplierController extends AbstractAdminController { protected static string $base_path = '/en/supplier'; protected static string $entity_class = Supplier::class; diff --git a/tests/Controller/BulkInfoProviderImportControllerTest.php b/tests/Controller/BulkInfoProviderImportControllerTest.php index ec3629fe..8961d23b 100644 --- a/tests/Controller/BulkInfoProviderImportControllerTest.php +++ b/tests/Controller/BulkInfoProviderImportControllerTest.php @@ -22,8 +22,6 @@ declare(strict_types=1); namespace App\Tests\Controller; -use App\Services\InfoProviderSystem\BulkInfoProviderService; -use App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO; use App\Entity\InfoProviderSystem\BulkImportJobStatus; use App\Entity\InfoProviderSystem\BulkInfoProviderImportJob; use App\Entity\Parts\Part; @@ -38,7 +36,7 @@ use Symfony\Component\HttpFoundation\Response; #[Group("slow")] #[Group("DB")] -final class BulkInfoProviderImportControllerTest extends WebTestCase +class BulkInfoProviderImportControllerTest extends WebTestCase { public function testStep1WithoutIds(): void { @@ -176,8 +174,8 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase // Verify the template rendered the source_field and source_keyword correctly $content = $client->getResponse()->getContent(); - $this->assertStringContainsString('test_field', (string) $content); - $this->assertStringContainsString('test_keyword', (string) $content); + $this->assertStringContainsString('test_field', $content); + $this->assertStringContainsString('test_keyword', $content); // Clean up - find by ID to avoid detached entity issues $jobId = $job->getId(); @@ -609,7 +607,7 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase } $this->assertResponseStatusCodeSame(Response::HTTP_OK); - $this->assertStringContainsString('Bulk Info Provider Import', (string) $client->getResponse()->getContent()); + $this->assertStringContainsString('Bulk Info Provider Import', $client->getResponse()->getContent()); } public function testStep1FormSubmissionWithErrors(): void @@ -632,7 +630,7 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase } $this->assertResponseStatusCodeSame(Response::HTTP_OK); - $this->assertStringContainsString('Bulk Info Provider Import', (string) $client->getResponse()->getContent()); + $this->assertStringContainsString('Bulk Info Provider Import', $client->getResponse()->getContent()); } public function testBulkInfoProviderServiceKeywordExtraction(): void @@ -649,18 +647,18 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can extract keywords from parts - $bulkService = $client->getContainer()->get(BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); // Create field mappings to verify the service works $fieldMappings = [ - new BulkSearchFieldMappingDTO('name', ['test'], 1), - new BulkSearchFieldMappingDTO('mpn', ['test'], 2) + new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('name', ['test'], 1), + new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('mpn', ['test'], 2) ]; // The service may return an empty result or throw when no results are found try { $result = $bulkService->performBulkSearch([$part], $fieldMappings, false); - $this->assertInstanceOf(BulkSearchResponseDTO::class, $result); + $this->assertInstanceOf(\App\Services\InfoProviderSystem\DTOs\BulkSearchResponseDTO::class, $result); } catch (\RuntimeException $e) { $this->assertStringContainsString('No search results found', $e->getMessage()); } @@ -727,12 +725,12 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can handle supplier part number fields - $bulkService = $client->getContainer()->get(BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); // Create field mappings with supplier SPN field mapping $fieldMappings = [ - new BulkSearchFieldMappingDTO('invalid_field', ['test'], 1), - new BulkSearchFieldMappingDTO('test_supplier_spn', ['test'], 2) + new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('invalid_field', ['test'], 1), + new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('test_supplier_spn', ['test'], 2) ]; // The service should be able to process the request and throw an exception when no results are found @@ -758,11 +756,11 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can handle batch processing - $bulkService = $client->getContainer()->get(BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); // Create field mappings with multiple keywords $fieldMappings = [ - new BulkSearchFieldMappingDTO('empty', ['test'], 1) + new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('empty', ['test'], 1) ]; // The service should be able to process the request and throw an exception when no results are found @@ -788,7 +786,7 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can handle prefetch details - $bulkService = $client->getContainer()->get(BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); // Create empty search results to test prefetch method $searchResults = new BulkSearchResponseDTO([ diff --git a/tests/Controller/KiCadApiControllerTest.php b/tests/Controller/KiCadApiControllerTest.php index 9d33512a..a66cb8a4 100644 --- a/tests/Controller/KiCadApiControllerTest.php +++ b/tests/Controller/KiCadApiControllerTest.php @@ -27,7 +27,7 @@ use App\DataFixtures\APITokenFixtures; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class KiCadApiControllerTest extends WebTestCase +class KiCadApiControllerTest extends WebTestCase { private const BASE_URL = '/en/kicad-api/v1'; diff --git a/tests/Controller/PartControllerTest.php b/tests/Controller/PartControllerTest.php index c15bdd51..8c9f3729 100644 --- a/tests/Controller/PartControllerTest.php +++ b/tests/Controller/PartControllerTest.php @@ -38,7 +38,7 @@ use Symfony\Component\HttpFoundation\Response; #[Group("slow")] #[Group("DB")] -final class PartControllerTest extends WebTestCase +class PartControllerTest extends WebTestCase { public function testShowPart(): void { diff --git a/tests/Controller/RedirectControllerTest.php b/tests/Controller/RedirectControllerTest.php index 420b0f49..ac2776e5 100644 --- a/tests/Controller/RedirectControllerTest.php +++ b/tests/Controller/RedirectControllerTest.php @@ -33,7 +33,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; #[Group('slow')] #[Group('DB')] -final class RedirectControllerTest extends WebTestCase +class RedirectControllerTest extends WebTestCase { protected EntityManagerInterface $em; protected UserRepository $userRepo; diff --git a/tests/Controller/ScanControllerTest.php b/tests/Controller/ScanControllerTest.php index b504cd29..98992e09 100644 --- a/tests/Controller/ScanControllerTest.php +++ b/tests/Controller/ScanControllerTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Controller; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class ScanControllerTest extends WebTestCase +class ScanControllerTest extends WebTestCase { private ?KernelBrowser $client = null; diff --git a/tests/DataTables/Filters/CompoundFilterTraitTest.php b/tests/DataTables/Filters/CompoundFilterTraitTest.php index d9bf20b0..93f3c1e1 100644 --- a/tests/DataTables/Filters/CompoundFilterTraitTest.php +++ b/tests/DataTables/Filters/CompoundFilterTraitTest.php @@ -27,7 +27,7 @@ use App\DataTables\Filters\FilterInterface; use Doctrine\ORM\QueryBuilder; use PHPUnit\Framework\TestCase; -final class CompoundFilterTraitTest extends TestCase +class CompoundFilterTraitTest extends TestCase { public function testFindAllChildFiltersEmpty(): void @@ -49,9 +49,9 @@ final class CompoundFilterTraitTest extends TestCase public function testFindAllChildFilters(): void { - $f1 = $this->createStub(FilterInterface::class); - $f2 = $this->createStub(FilterInterface::class); - $f3 = $this->createStub(FilterInterface::class); + $f1 = $this->createMock(FilterInterface::class); + $f2 = $this->createMock(FilterInterface::class); + $f3 = $this->createMock(FilterInterface::class); $filter = new class($f1, $f2, $f3, null) { use CompoundFilterTrait; @@ -108,7 +108,7 @@ final class CompoundFilterTraitTest extends TestCase } }; - $qb = $this->createStub(QueryBuilder::class); + $qb = $this->createMock(QueryBuilder::class); $filter->_applyAllChildFilters($qb); } diff --git a/tests/DataTables/Filters/Constraints/FilterTraitTest.php b/tests/DataTables/Filters/Constraints/FilterTraitTest.php index a7493dcf..e1e459d5 100644 --- a/tests/DataTables/Filters/Constraints/FilterTraitTest.php +++ b/tests/DataTables/Filters/Constraints/FilterTraitTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\DataTables\Filters\Constraints\FilterTrait; use PHPUnit\Framework\TestCase; -final class FilterTraitTest extends TestCase +class FilterTraitTest extends TestCase { use FilterTrait; diff --git a/tests/DataTables/Filters/Constraints/Part/BulkImportJobStatusConstraintTest.php b/tests/DataTables/Filters/Constraints/Part/BulkImportJobStatusConstraintTest.php index 333b9af5..816a8035 100644 --- a/tests/DataTables/Filters/Constraints/Part/BulkImportJobStatusConstraintTest.php +++ b/tests/DataTables/Filters/Constraints/Part/BulkImportJobStatusConstraintTest.php @@ -28,7 +28,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use PHPUnit\Framework\TestCase; -final class BulkImportJobStatusConstraintTest extends TestCase +class BulkImportJobStatusConstraintTest extends TestCase { private BulkImportJobStatusConstraint $constraint; private QueryBuilder $queryBuilder; @@ -46,7 +46,7 @@ final class BulkImportJobStatusConstraintTest extends TestCase public function testConstructor(): void { - $this->assertSame([], $this->constraint->getValue()); + $this->assertEquals([], $this->constraint->getValue()); $this->assertEmpty($this->constraint->getOperator()); $this->assertFalse($this->constraint->isEnabled()); } @@ -56,7 +56,7 @@ final class BulkImportJobStatusConstraintTest extends TestCase $values = ['pending', 'in_progress']; $this->constraint->setValue($values); - $this->assertSame($values, $this->constraint->getValue()); + $this->assertEquals($values, $this->constraint->getValue()); } public function testGetAndSetOperator(): void @@ -64,7 +64,7 @@ final class BulkImportJobStatusConstraintTest extends TestCase $operator = 'ANY'; $this->constraint->setOperator($operator); - $this->assertSame($operator, $this->constraint->getOperator()); + $this->assertEquals($operator, $this->constraint->getOperator()); } public function testIsEnabledWithEmptyValues(): void diff --git a/tests/DataTables/Filters/Constraints/Part/BulkImportPartStatusConstraintTest.php b/tests/DataTables/Filters/Constraints/Part/BulkImportPartStatusConstraintTest.php index e2b37287..bc110eda 100644 --- a/tests/DataTables/Filters/Constraints/Part/BulkImportPartStatusConstraintTest.php +++ b/tests/DataTables/Filters/Constraints/Part/BulkImportPartStatusConstraintTest.php @@ -28,7 +28,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use PHPUnit\Framework\TestCase; -final class BulkImportPartStatusConstraintTest extends TestCase +class BulkImportPartStatusConstraintTest extends TestCase { private BulkImportPartStatusConstraint $constraint; private QueryBuilder $queryBuilder; @@ -46,7 +46,7 @@ final class BulkImportPartStatusConstraintTest extends TestCase public function testConstructor(): void { - $this->assertSame([], $this->constraint->getValue()); + $this->assertEquals([], $this->constraint->getValue()); $this->assertEmpty($this->constraint->getOperator()); $this->assertFalse($this->constraint->isEnabled()); } @@ -56,7 +56,7 @@ final class BulkImportPartStatusConstraintTest extends TestCase $values = ['pending', 'completed', 'skipped']; $this->constraint->setValue($values); - $this->assertSame($values, $this->constraint->getValue()); + $this->assertEquals($values, $this->constraint->getValue()); } public function testGetAndSetOperator(): void @@ -64,7 +64,7 @@ final class BulkImportPartStatusConstraintTest extends TestCase $operator = 'ANY'; $this->constraint->setOperator($operator); - $this->assertSame($operator, $this->constraint->getOperator()); + $this->assertEquals($operator, $this->constraint->getOperator()); } public function testIsEnabledWithEmptyValues(): void @@ -294,6 +294,6 @@ final class BulkImportPartStatusConstraintTest extends TestCase $this->constraint->apply($this->queryBuilder); - $this->assertSame($statusValues, $this->constraint->getValue()); + $this->assertEquals($statusValues, $this->constraint->getValue()); } } diff --git a/tests/DatatablesAvailabilityTest.php b/tests/DatatablesAvailabilityTest.php index 1447da73..dad61be3 100644 --- a/tests/DatatablesAvailabilityTest.php +++ b/tests/DatatablesAvailabilityTest.php @@ -44,7 +44,7 @@ namespace App\Tests; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class DatatablesAvailabilityTest extends WebTestCase +class DatatablesAvailabilityTest extends WebTestCase { #[DataProvider('urlProvider')] public function testDataTable(string $url, ?array $ordering = null): void diff --git a/tests/Doctrine/SQLiteRegexMiddlewareTest.php b/tests/Doctrine/SQLiteRegexMiddlewareTest.php index aa5e4da1..67410f76 100644 --- a/tests/Doctrine/SQLiteRegexMiddlewareTest.php +++ b/tests/Doctrine/SQLiteRegexMiddlewareTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Doctrine\Middleware\SQLiteRegexExtensionMiddlewareDriver; use PHPUnit\Framework\TestCase; -final class SQLiteRegexMiddlewareTest extends TestCase +class SQLiteRegexMiddlewareTest extends TestCase { public static function regexpDataProvider(): \Generator diff --git a/tests/Entity/Attachments/AttachmentTest.php b/tests/Entity/Attachments/AttachmentTest.php index ca55424c..35222d63 100644 --- a/tests/Entity/Attachments/AttachmentTest.php +++ b/tests/Entity/Attachments/AttachmentTest.php @@ -55,7 +55,7 @@ use InvalidArgumentException; use PHPUnit\Framework\TestCase; use ReflectionClass; -final class AttachmentTest extends TestCase +class AttachmentTest extends TestCase { public function testEmptyState(): void { diff --git a/tests/Entity/Attachments/AttachmentTypeTest.php b/tests/Entity/Attachments/AttachmentTypeTest.php index c966d23f..ea80db11 100644 --- a/tests/Entity/Attachments/AttachmentTypeTest.php +++ b/tests/Entity/Attachments/AttachmentTypeTest.php @@ -28,7 +28,7 @@ use App\Entity\Attachments\UserAttachment; use Doctrine\Common\Collections\Collection; use PHPUnit\Framework\TestCase; -final class AttachmentTypeTest extends TestCase +class AttachmentTypeTest extends TestCase { public function testEmptyState(): void { diff --git a/tests/Entity/Base/AbstractStructuralDBElementTest.php b/tests/Entity/Base/AbstractStructuralDBElementTest.php index 90a7dee2..3f8157ad 100644 --- a/tests/Entity/Base/AbstractStructuralDBElementTest.php +++ b/tests/Entity/Base/AbstractStructuralDBElementTest.php @@ -31,7 +31,7 @@ use PHPUnit\Framework\TestCase; * Test StructuralDBElement entities. * Note: Because StructuralDBElement is abstract we use AttachmentType here as a placeholder. */ -final class AbstractStructuralDBElementTest extends TestCase +class AbstractStructuralDBElementTest extends TestCase { protected AttachmentType $root; protected AttachmentType $child1; diff --git a/tests/Entity/BulkImportJobStatusTest.php b/tests/Entity/BulkImportJobStatusTest.php index c38d62e2..e8b4a977 100644 --- a/tests/Entity/BulkImportJobStatusTest.php +++ b/tests/Entity/BulkImportJobStatusTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Entity; use App\Entity\InfoProviderSystem\BulkImportJobStatus; use PHPUnit\Framework\TestCase; -final class BulkImportJobStatusTest extends TestCase +class BulkImportJobStatusTest extends TestCase { public function testEnumValues(): void { diff --git a/tests/Entity/BulkInfoProviderImportJobPartTest.php b/tests/Entity/BulkInfoProviderImportJobPartTest.php index 94b05637..dd9600dd 100644 --- a/tests/Entity/BulkInfoProviderImportJobPartTest.php +++ b/tests/Entity/BulkInfoProviderImportJobPartTest.php @@ -28,25 +28,32 @@ use App\Entity\InfoProviderSystem\BulkInfoProviderImportJobPart; use App\Entity\Parts\Part; use PHPUnit\Framework\TestCase; -final class BulkInfoProviderImportJobPartTest extends TestCase +class BulkInfoProviderImportJobPartTest extends TestCase { + private BulkInfoProviderImportJob $job; + private Part $part; private BulkInfoProviderImportJobPart $jobPart; protected function setUp(): void { - $this->jobPart = new BulkInfoProviderImportJobPart($this->createStub(BulkInfoProviderImportJob::class), $this->createStub(Part::class)); + $this->job = $this->createMock(BulkInfoProviderImportJob::class); + $this->part = $this->createMock(Part::class); + + $this->jobPart = new BulkInfoProviderImportJobPart($this->job, $this->part); } public function testConstructor(): void { - $this->assertSame(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); + $this->assertSame($this->job, $this->jobPart->getJob()); + $this->assertSame($this->part, $this->jobPart->getPart()); + $this->assertEquals(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); $this->assertNull($this->jobPart->getReason()); $this->assertNull($this->jobPart->getCompletedAt()); } public function testGetAndSetJob(): void { - $newJob = $this->createStub(BulkInfoProviderImportJob::class); + $newJob = $this->createMock(BulkInfoProviderImportJob::class); $result = $this->jobPart->setJob($newJob); @@ -56,7 +63,7 @@ final class BulkInfoProviderImportJobPartTest extends TestCase public function testGetAndSetPart(): void { - $newPart = $this->createStub(Part::class); + $newPart = $this->createMock(Part::class); $result = $this->jobPart->setPart($newPart); @@ -69,7 +76,7 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->setStatus(BulkImportPartStatus::COMPLETED); $this->assertSame($this->jobPart, $result); - $this->assertSame(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); + $this->assertEquals(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); } public function testGetAndSetReason(): void @@ -79,7 +86,7 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->setReason($reason); $this->assertSame($this->jobPart, $result); - $this->assertSame($reason, $this->jobPart->getReason()); + $this->assertEquals($reason, $this->jobPart->getReason()); } public function testGetAndSetCompletedAt(): void @@ -101,7 +108,7 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $afterTime = new \DateTimeImmutable(); $this->assertSame($this->jobPart, $result); - $this->assertSame(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); + $this->assertEquals(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); $this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt()); $this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt()); @@ -117,8 +124,8 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $afterTime = new \DateTimeImmutable(); $this->assertSame($this->jobPart, $result); - $this->assertSame(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); - $this->assertSame($reason, $this->jobPart->getReason()); + $this->assertEquals(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); + $this->assertEquals($reason, $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); $this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt()); $this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt()); @@ -129,8 +136,8 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->markAsSkipped(); $this->assertSame($this->jobPart, $result); - $this->assertSame(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); - $this->assertSame('', $this->jobPart->getReason()); + $this->assertEquals(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); + $this->assertEquals('', $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); } @@ -144,8 +151,8 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $afterTime = new \DateTimeImmutable(); $this->assertSame($this->jobPart, $result); - $this->assertSame(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); - $this->assertSame($reason, $this->jobPart->getReason()); + $this->assertEquals(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); + $this->assertEquals($reason, $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); $this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt()); $this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt()); @@ -156,8 +163,8 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->markAsFailed(); $this->assertSame($this->jobPart, $result); - $this->assertSame(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); - $this->assertSame('', $this->jobPart->getReason()); + $this->assertEquals(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); + $this->assertEquals('', $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); } @@ -169,7 +176,7 @@ final class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->markAsPending(); $this->assertSame($this->jobPart, $result); - $this->assertSame(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); + $this->assertEquals(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); $this->assertNull($this->jobPart->getReason()); $this->assertNull($this->jobPart->getCompletedAt()); } @@ -274,7 +281,7 @@ final class BulkInfoProviderImportJobPartTest extends TestCase // After marking as skipped, should have reason and completion time $this->jobPart->markAsSkipped('Skipped reason'); - $this->assertSame('Skipped reason', $this->jobPart->getReason()); + $this->assertEquals('Skipped reason', $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); // After marking as pending, reason and completion time should be cleared @@ -284,7 +291,7 @@ final class BulkInfoProviderImportJobPartTest extends TestCase // After marking as failed, should have reason and completion time $this->jobPart->markAsFailed('Failed reason'); - $this->assertSame('Failed reason', $this->jobPart->getReason()); + $this->assertEquals('Failed reason', $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); // After marking as completed, should have completion time (reason may remain from previous state) diff --git a/tests/Entity/BulkInfoProviderImportJobTest.php b/tests/Entity/BulkInfoProviderImportJobTest.php index d1a854cd..c9841ac4 100644 --- a/tests/Entity/BulkInfoProviderImportJobTest.php +++ b/tests/Entity/BulkInfoProviderImportJobTest.php @@ -22,8 +22,6 @@ declare(strict_types=1); namespace App\Tests\Entity; -use App\Entity\Parts\Part; -use App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO; use App\Entity\InfoProviderSystem\BulkImportJobStatus; use App\Entity\InfoProviderSystem\BulkInfoProviderImportJob; use App\Entity\UserSystem\User; @@ -33,7 +31,7 @@ use App\Services\InfoProviderSystem\DTOs\BulkSearchResponseDTO; use App\Services\InfoProviderSystem\DTOs\SearchResultDTO; use PHPUnit\Framework\TestCase; -final class BulkInfoProviderImportJobTest extends TestCase +class BulkInfoProviderImportJobTest extends TestCase { private BulkInfoProviderImportJob $job; private User $user; @@ -47,9 +45,9 @@ final class BulkInfoProviderImportJobTest extends TestCase $this->job->setCreatedBy($this->user); } - private function createMockPart(int $id): Part + private function createMockPart(int $id): \App\Entity\Parts\Part { - $part = $this->createMock(Part::class); + $part = $this->createMock(\App\Entity\Parts\Part::class); $part->method('getId')->willReturn($id); $part->method('getName')->willReturn("Test Part {$id}"); return $part; @@ -60,7 +58,7 @@ final class BulkInfoProviderImportJobTest extends TestCase $job = new BulkInfoProviderImportJob(); $this->assertInstanceOf(\DateTimeImmutable::class, $job->getCreatedAt()); - $this->assertSame(BulkImportJobStatus::PENDING, $job->getStatus()); + $this->assertEquals(BulkImportJobStatus::PENDING, $job->getStatus()); $this->assertEmpty($job->getPartIds()); $this->assertEmpty($job->getFieldMappings()); $this->assertEmpty($job->getSearchResultsRaw()); @@ -72,14 +70,14 @@ final class BulkInfoProviderImportJobTest extends TestCase public function testBasicGettersSetters(): void { $this->job->setName('Test Job'); - $this->assertSame('Test Job', $this->job->getName()); + $this->assertEquals('Test Job', $this->job->getName()); // Test with actual parts - this is what actually works $parts = [$this->createMockPart(1), $this->createMockPart(2), $this->createMockPart(3)]; foreach ($parts as $part) { $this->job->addPart($part); } - $this->assertSame([1, 2, 3], $this->job->getPartIds()); + $this->assertEquals([1, 2, 3], $this->job->getPartIds()); $fieldMappings = [new BulkSearchFieldMappingDTO(field: 'field1', providers: ['provider1', 'provider2'])]; $this->job->setFieldMappings($fieldMappings); @@ -100,24 +98,24 @@ final class BulkInfoProviderImportJobTest extends TestCase $this->assertFalse($this->job->isStopped()); $this->job->markAsInProgress(); - $this->assertSame(BulkImportJobStatus::IN_PROGRESS, $this->job->getStatus()); + $this->assertEquals(BulkImportJobStatus::IN_PROGRESS, $this->job->getStatus()); $this->assertTrue($this->job->isInProgress()); $this->assertFalse($this->job->isPending()); $this->job->markAsCompleted(); - $this->assertSame(BulkImportJobStatus::COMPLETED, $this->job->getStatus()); + $this->assertEquals(BulkImportJobStatus::COMPLETED, $this->job->getStatus()); $this->assertTrue($this->job->isCompleted()); $this->assertNotNull($this->job->getCompletedAt()); $job2 = new BulkInfoProviderImportJob(); $job2->markAsFailed(); - $this->assertSame(BulkImportJobStatus::FAILED, $job2->getStatus()); + $this->assertEquals(BulkImportJobStatus::FAILED, $job2->getStatus()); $this->assertTrue($job2->isFailed()); $this->assertNotNull($job2->getCompletedAt()); $job3 = new BulkInfoProviderImportJob(); $job3->markAsStopped(); - $this->assertSame(BulkImportJobStatus::STOPPED, $job3->getStatus()); + $this->assertEquals(BulkImportJobStatus::STOPPED, $job3->getStatus()); $this->assertTrue($job3->isStopped()); $this->assertNotNull($job3->getCompletedAt()); } @@ -141,7 +139,7 @@ final class BulkInfoProviderImportJobTest extends TestCase public function testPartCount(): void { - $this->assertSame(0, $this->job->getPartCount()); + $this->assertEquals(0, $this->job->getPartCount()); // Test with actual parts - setPartIds doesn't actually add parts $parts = [ @@ -154,31 +152,31 @@ final class BulkInfoProviderImportJobTest extends TestCase foreach ($parts as $part) { $this->job->addPart($part); } - $this->assertSame(5, $this->job->getPartCount()); + $this->assertEquals(5, $this->job->getPartCount()); } public function testResultCount(): void { - $this->assertSame(0, $this->job->getResultCount()); + $this->assertEquals(0, $this->job->getResultCount()); $searchResults = new BulkSearchResponseDTO([ - new BulkSearchPartResultsDTO( + new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO( part: $this->createMockPart(1), searchResults: [new BulkSearchPartResultDTO(searchResult: new SearchResultDTO(provider_key: 'dummy', provider_id: '1234', name: 'Part 1', description: 'A part'))] ), - new BulkSearchPartResultsDTO( + new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO( part: $this->createMockPart(2), searchResults: [new BulkSearchPartResultDTO(searchResult: new SearchResultDTO(provider_key: 'dummy', provider_id: '1234', name: 'Part 2', description: 'A part')), new BulkSearchPartResultDTO(searchResult: new SearchResultDTO(provider_key: 'dummy', provider_id: '5678', name: 'Part 2 Alt', description: 'Another part'))] ), - new BulkSearchPartResultsDTO( + new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO( part: $this->createMockPart(3), searchResults: [] ) ]); $this->job->setSearchResults($searchResults); - $this->assertSame(3, $this->job->getResultCount()); + $this->assertEquals(3, $this->job->getResultCount()); } public function testPartProgressTracking(): void @@ -224,21 +222,21 @@ final class BulkInfoProviderImportJobTest extends TestCase $this->job->addPart($part); } - $this->assertSame(0, $this->job->getCompletedPartsCount()); - $this->assertSame(0, $this->job->getSkippedPartsCount()); + $this->assertEquals(0, $this->job->getCompletedPartsCount()); + $this->assertEquals(0, $this->job->getSkippedPartsCount()); $this->job->markPartAsCompleted(1); $this->job->markPartAsCompleted(2); $this->job->markPartAsSkipped(3, 'Error'); - $this->assertSame(2, $this->job->getCompletedPartsCount()); - $this->assertSame(1, $this->job->getSkippedPartsCount()); + $this->assertEquals(2, $this->job->getCompletedPartsCount()); + $this->assertEquals(1, $this->job->getSkippedPartsCount()); } public function testProgressPercentage(): void { $emptyJob = new BulkInfoProviderImportJob(); - $this->assertEqualsWithDelta(100.0, $emptyJob->getProgressPercentage(), PHP_FLOAT_EPSILON); + $this->assertEquals(100.0, $emptyJob->getProgressPercentage()); // Test with actual parts - setPartIds doesn't actually add parts $parts = [ @@ -252,18 +250,18 @@ final class BulkInfoProviderImportJobTest extends TestCase $this->job->addPart($part); } - $this->assertEqualsWithDelta(0.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); + $this->assertEquals(0.0, $this->job->getProgressPercentage()); $this->job->markPartAsCompleted(1); $this->job->markPartAsCompleted(2); - $this->assertEqualsWithDelta(40.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); + $this->assertEquals(40.0, $this->job->getProgressPercentage()); $this->job->markPartAsSkipped(3, 'Error'); - $this->assertEqualsWithDelta(60.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); + $this->assertEquals(60.0, $this->job->getProgressPercentage()); $this->job->markPartAsCompleted(4); $this->job->markPartAsCompleted(5); - $this->assertEqualsWithDelta(100.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); + $this->assertEquals(100.0, $this->job->getProgressPercentage()); } public function testIsAllPartsCompleted(): void @@ -303,8 +301,8 @@ final class BulkInfoProviderImportJobTest extends TestCase $this->job->addPart($part); } - $this->assertSame('info_providers.bulk_import.job_name_template', $this->job->getDisplayNameKey()); - $this->assertSame(['%count%' => 3], $this->job->getDisplayNameParams()); + $this->assertEquals('info_providers.bulk_import.job_name_template', $this->job->getDisplayNameKey()); + $this->assertEquals(['%count%' => 3], $this->job->getDisplayNameParams()); } public function testFormattedTimestamp(): void diff --git a/tests/Entity/LogSystem/AbstractLogEntryTest.php b/tests/Entity/LogSystem/AbstractLogEntryTest.php index d99b8e73..3f223693 100644 --- a/tests/Entity/LogSystem/AbstractLogEntryTest.php +++ b/tests/Entity/LogSystem/AbstractLogEntryTest.php @@ -58,7 +58,7 @@ use App\Entity\UserSystem\Group; use App\Entity\UserSystem\User; use PHPUnit\Framework\TestCase; -final class AbstractLogEntryTest extends TestCase +class AbstractLogEntryTest extends TestCase { public function testSetGetTarget(): void { diff --git a/tests/Entity/LogSystem/LogLevelTest.php b/tests/Entity/LogSystem/LogLevelTest.php index 0125b0cd..402942e1 100644 --- a/tests/Entity/LogSystem/LogLevelTest.php +++ b/tests/Entity/LogSystem/LogLevelTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Entity\LogSystem; use App\Entity\LogSystem\LogLevel; use PHPUnit\Framework\TestCase; -final class LogLevelTest extends TestCase +class LogLevelTest extends TestCase { public function testToPSR3LevelString(): void diff --git a/tests/Entity/LogSystem/LogTargetTypeTest.php b/tests/Entity/LogSystem/LogTargetTypeTest.php index 06e2ead1..46682496 100644 --- a/tests/Entity/LogSystem/LogTargetTypeTest.php +++ b/tests/Entity/LogSystem/LogTargetTypeTest.php @@ -30,7 +30,7 @@ use App\Entity\Parts\Category; use App\Entity\UserSystem\User; use PHPUnit\Framework\TestCase; -final class LogTargetTypeTest extends TestCase +class LogTargetTypeTest extends TestCase { public function testToClass(): void diff --git a/tests/Entity/Parameters/PartParameterTest.php b/tests/Entity/Parameters/PartParameterTest.php index 6a07468e..64550eee 100644 --- a/tests/Entity/Parameters/PartParameterTest.php +++ b/tests/Entity/Parameters/PartParameterTest.php @@ -45,7 +45,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Entity\Parameters\PartParameter; use PHPUnit\Framework\TestCase; -final class PartParameterTest extends TestCase +class PartParameterTest extends TestCase { public static function valueWithUnitDataProvider(): \Iterator { diff --git a/tests/Entity/Parts/InfoProviderReferenceTest.php b/tests/Entity/Parts/InfoProviderReferenceTest.php index dcc6a43c..a1a8d5de 100644 --- a/tests/Entity/Parts/InfoProviderReferenceTest.php +++ b/tests/Entity/Parts/InfoProviderReferenceTest.php @@ -26,7 +26,7 @@ use App\Entity\Parts\InfoProviderReference; use App\Services\InfoProviderSystem\DTOs\PartDetailDTO; use PHPUnit\Framework\TestCase; -final class InfoProviderReferenceTest extends TestCase +class InfoProviderReferenceTest extends TestCase { public function testNoProvider(): void { diff --git a/tests/Entity/Parts/PartAssociationTest.php b/tests/Entity/Parts/PartAssociationTest.php index 25487d1f..e002846e 100644 --- a/tests/Entity/Parts/PartAssociationTest.php +++ b/tests/Entity/Parts/PartAssociationTest.php @@ -26,7 +26,7 @@ use App\Entity\Parts\AssociationType; use App\Entity\Parts\PartAssociation; use PHPUnit\Framework\TestCase; -final class PartAssociationTest extends TestCase +class PartAssociationTest extends TestCase { public function testGetTypeTranslationKey(): void diff --git a/tests/Entity/Parts/PartLotTest.php b/tests/Entity/Parts/PartLotTest.php index 10cc80b9..30687b72 100644 --- a/tests/Entity/Parts/PartLotTest.php +++ b/tests/Entity/Parts/PartLotTest.php @@ -26,7 +26,7 @@ use App\Entity\Parts\PartLot; use DateTime; use PHPUnit\Framework\TestCase; -final class PartLotTest extends TestCase +class PartLotTest extends TestCase { public function testIsExpired(): void { diff --git a/tests/Entity/Parts/PartTest.php b/tests/Entity/Parts/PartTest.php index e855c340..c1ae8935 100644 --- a/tests/Entity/Parts/PartTest.php +++ b/tests/Entity/Parts/PartTest.php @@ -29,7 +29,7 @@ use DateTime; use Doctrine\Common\Collections\Collection; use PHPUnit\Framework\TestCase; -final class PartTest extends TestCase +class PartTest extends TestCase { public function testAddRemovePartLot(): void { diff --git a/tests/Entity/PriceSystem/CurrencyTest.php b/tests/Entity/PriceSystem/CurrencyTest.php index 018092e5..0058d501 100644 --- a/tests/Entity/PriceSystem/CurrencyTest.php +++ b/tests/Entity/PriceSystem/CurrencyTest.php @@ -26,7 +26,7 @@ use App\Entity\PriceInformations\Currency; use Brick\Math\BigDecimal; use PHPUnit\Framework\TestCase; -final class CurrencyTest extends TestCase +class CurrencyTest extends TestCase { public function testGetInverseExchangeRate(): void { diff --git a/tests/Entity/PriceSystem/OrderdetailTest.php b/tests/Entity/PriceSystem/OrderdetailTest.php index 2becb74e..df86ab34 100644 --- a/tests/Entity/PriceSystem/OrderdetailTest.php +++ b/tests/Entity/PriceSystem/OrderdetailTest.php @@ -27,7 +27,7 @@ use App\Entity\PriceInformations\Pricedetail; use Doctrine\Common\Collections\Collection; use PHPUnit\Framework\TestCase; -final class OrderdetailTest extends TestCase +class OrderdetailTest extends TestCase { public function testAddRemovePricdetails(): void { diff --git a/tests/Entity/PriceSystem/PricedetailTest.php b/tests/Entity/PriceSystem/PricedetailTest.php index effe6fd6..8a3cf328 100644 --- a/tests/Entity/PriceSystem/PricedetailTest.php +++ b/tests/Entity/PriceSystem/PricedetailTest.php @@ -28,7 +28,7 @@ use App\Entity\PriceInformations\Pricedetail; use Brick\Math\BigDecimal; use PHPUnit\Framework\TestCase; -final class PricedetailTest extends TestCase +class PricedetailTest extends TestCase { public function testGetPricePerUnit(): void { diff --git a/tests/Entity/UserSystem/ApiTokenTypeTest.php b/tests/Entity/UserSystem/ApiTokenTypeTest.php index 7a4506ba..a8e520f1 100644 --- a/tests/Entity/UserSystem/ApiTokenTypeTest.php +++ b/tests/Entity/UserSystem/ApiTokenTypeTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Entity\UserSystem; use App\Entity\UserSystem\ApiTokenType; use PHPUnit\Framework\TestCase; -final class ApiTokenTypeTest extends TestCase +class ApiTokenTypeTest extends TestCase { public function testGetTokenPrefix(): void diff --git a/tests/Entity/UserSystem/PermissionDataTest.php b/tests/Entity/UserSystem/PermissionDataTest.php index 3d250a81..4fd8c5ce 100644 --- a/tests/Entity/UserSystem/PermissionDataTest.php +++ b/tests/Entity/UserSystem/PermissionDataTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Entity\UserSystem; use App\Entity\UserSystem\PermissionData; use PHPUnit\Framework\TestCase; -final class PermissionDataTest extends TestCase +class PermissionDataTest extends TestCase { public function testGetSetIs(): void diff --git a/tests/Entity/UserSystem/UserTest.php b/tests/Entity/UserSystem/UserTest.php index 12797ad1..a4349e1d 100644 --- a/tests/Entity/UserSystem/UserTest.php +++ b/tests/Entity/UserSystem/UserTest.php @@ -31,7 +31,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Uid\Uuid; use Webauthn\TrustPath\EmptyTrustPath; -final class UserTest extends TestCase +class UserTest extends TestCase { public function testGetFullName(): void { diff --git a/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php b/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php index c4c9f04b..4099f0ee 100644 --- a/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php +++ b/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\EnvVarProcessors; use App\EnvVarProcessors\AddSlashEnvVarProcessor; use PHPUnit\Framework\TestCase; -final class AddSlashEnvVarProcessorTest extends TestCase +class AddSlashEnvVarProcessorTest extends TestCase { protected AddSlashEnvVarProcessor $processor; diff --git a/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php b/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php index 3a35c670..58573ae6 100644 --- a/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php +++ b/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\EventListener; use App\EventListener\RegisterSynonymsAsTranslationParametersListener; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class RegisterSynonymsAsTranslationParametersTest extends KernelTestCase +class RegisterSynonymsAsTranslationParametersTest extends KernelTestCase { private RegisterSynonymsAsTranslationParametersListener $listener; diff --git a/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php b/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php index 3d2089e1..0eaf931c 100644 --- a/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php +++ b/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php @@ -33,7 +33,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\Uid\Uuid; use Webauthn\TrustPath\EmptyTrustPath; -final class PasswordChangeNeededSubscriberTest extends TestCase +class PasswordChangeNeededSubscriberTest extends TestCase { public function testTFARedirectNeeded(): void { diff --git a/tests/Exceptions/TwigModeExceptionTest.php b/tests/Exceptions/TwigModeExceptionTest.php index 09468291..686a87a2 100644 --- a/tests/Exceptions/TwigModeExceptionTest.php +++ b/tests/Exceptions/TwigModeExceptionTest.php @@ -27,7 +27,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Twig\Error\Error; -final class TwigModeExceptionTest extends KernelTestCase +class TwigModeExceptionTest extends KernelTestCase { private string $projectPath; diff --git a/tests/Form/InfoProviderSystem/GlobalFieldMappingTypeTest.php b/tests/Form/InfoProviderSystem/GlobalFieldMappingTypeTest.php index 07106505..89e362e4 100644 --- a/tests/Form/InfoProviderSystem/GlobalFieldMappingTypeTest.php +++ b/tests/Form/InfoProviderSystem/GlobalFieldMappingTypeTest.php @@ -29,7 +29,7 @@ use Symfony\Component\Form\FormFactoryInterface; #[Group("slow")] #[Group("DB")] -final class GlobalFieldMappingTypeTest extends KernelTestCase +class GlobalFieldMappingTypeTest extends KernelTestCase { private FormFactoryInterface $formFactory; diff --git a/tests/Helpers/BBCodeToMarkdownConverterTest.php b/tests/Helpers/BBCodeToMarkdownConverterTest.php index 07fca505..9506cba4 100644 --- a/tests/Helpers/BBCodeToMarkdownConverterTest.php +++ b/tests/Helpers/BBCodeToMarkdownConverterTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Helpers\BBCodeToMarkdownConverter; use PHPUnit\Framework\TestCase; -final class BBCodeToMarkdownConverterTest extends TestCase +class BBCodeToMarkdownConverterTest extends TestCase { protected BBCodeToMarkdownConverter $converter; diff --git a/tests/Helpers/IPAnonymizerTest.php b/tests/Helpers/IPAnonymizerTest.php index 7efd27ac..e16368eb 100644 --- a/tests/Helpers/IPAnonymizerTest.php +++ b/tests/Helpers/IPAnonymizerTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Helpers\IPAnonymizer; use PHPUnit\Framework\TestCase; -final class IPAnonymizerTest extends TestCase +class IPAnonymizerTest extends TestCase { public static function anonymizeDataProvider(): \Generator diff --git a/tests/Helpers/Projects/ProjectBuildRequestTest.php b/tests/Helpers/Projects/ProjectBuildRequestTest.php index c1fd1498..1158d89a 100644 --- a/tests/Helpers/Projects/ProjectBuildRequestTest.php +++ b/tests/Helpers/Projects/ProjectBuildRequestTest.php @@ -30,7 +30,7 @@ use App\Entity\ProjectSystem\ProjectBOMEntry; use App\Helpers\Projects\ProjectBuildRequest; use PHPUnit\Framework\TestCase; -final class ProjectBuildRequestTest extends TestCase +class ProjectBuildRequestTest extends TestCase { /** @var Project */ diff --git a/tests/Helpers/TreeViewNodeTest.php b/tests/Helpers/TreeViewNodeTest.php index b1179f6c..9005651d 100644 --- a/tests/Helpers/TreeViewNodeTest.php +++ b/tests/Helpers/TreeViewNodeTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Helpers; use App\Helpers\Trees\TreeViewNode; use PHPUnit\Framework\TestCase; -final class TreeViewNodeTest extends TestCase +class TreeViewNodeTest extends TestCase { /** * @var TreeViewNode diff --git a/tests/Helpers/TrinaryLogicHelperTest.php b/tests/Helpers/TrinaryLogicHelperTest.php index 4b8c9f01..3082571b 100644 --- a/tests/Helpers/TrinaryLogicHelperTest.php +++ b/tests/Helpers/TrinaryLogicHelperTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Helpers; use App\Helpers\TrinaryLogicHelper; use PHPUnit\Framework\TestCase; -final class TrinaryLogicHelperTest extends TestCase +class TrinaryLogicHelperTest extends TestCase { public function testNot() diff --git a/tests/Repository/AttachmentContainingDBElementRepositoryTest.php b/tests/Repository/AttachmentContainingDBElementRepositoryTest.php index 38aca071..f61750d9 100644 --- a/tests/Repository/AttachmentContainingDBElementRepositoryTest.php +++ b/tests/Repository/AttachmentContainingDBElementRepositoryTest.php @@ -28,7 +28,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class AttachmentContainingDBElementRepositoryTest extends KernelTestCase +class AttachmentContainingDBElementRepositoryTest extends KernelTestCase { private EntityManagerInterface $entityManager; diff --git a/tests/Repository/DBElementRepositoryTest.php b/tests/Repository/DBElementRepositoryTest.php index 5f1ac0e1..05ede7e2 100644 --- a/tests/Repository/DBElementRepositoryTest.php +++ b/tests/Repository/DBElementRepositoryTest.php @@ -33,7 +33,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class DBElementRepositoryTest extends KernelTestCase +class DBElementRepositoryTest extends KernelTestCase { private EntityManagerInterface $entityManager; diff --git a/tests/Repository/LogEntryRepositoryTest.php b/tests/Repository/LogEntryRepositoryTest.php index 46093a9e..f6cc991d 100644 --- a/tests/Repository/LogEntryRepositoryTest.php +++ b/tests/Repository/LogEntryRepositoryTest.php @@ -33,7 +33,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class LogEntryRepositoryTest extends KernelTestCase +class LogEntryRepositoryTest extends KernelTestCase { private EntityManagerInterface $entityManager; @@ -75,7 +75,6 @@ final class LogEntryRepositoryTest extends KernelTestCase //We have a edit log entry for the category with ID 1 $category = $this->entityManager->find(Category::class, 1); $adminUser = $this->entityManager->getRepository(User::class)->findOneBy(['name' => 'admin']); - $this->assertInstanceOf(Category::class, $category); $user = $this->repo->getLastEditingUser($category); @@ -84,7 +83,6 @@ final class LogEntryRepositoryTest extends KernelTestCase //For the category 2, the user must be null $category = $this->entityManager->find(Category::class, 2); - $this->assertInstanceOf(Category::class, $category); $user = $this->repo->getLastEditingUser($category); $this->assertNull($user); } @@ -94,7 +92,6 @@ final class LogEntryRepositoryTest extends KernelTestCase //We have a edit log entry for the category with ID 1 $category = $this->entityManager->find(Category::class, 1); $adminUser = $this->entityManager->getRepository(User::class)->findOneBy(['name' => 'admin']); - $this->assertInstanceOf(Category::class, $category); $user = $this->repo->getCreatingUser($category); @@ -103,7 +100,6 @@ final class LogEntryRepositoryTest extends KernelTestCase //For the category 2, the user must be null $category = $this->entityManager->find(Category::class, 2); - $this->assertInstanceOf(Category::class, $category); $user = $this->repo->getCreatingUser($category); $this->assertNull($user); } @@ -123,7 +119,6 @@ final class LogEntryRepositoryTest extends KernelTestCase public function testGetElementExistedAtTimestamp(): void { $part = $this->entityManager->find(Part::class, 3); - $this->assertInstanceOf(Part::class, $part); //Assume that the part is existing now $this->assertTrue($this->repo->getElementExistedAtTimestamp($part, new \DateTimeImmutable())); @@ -135,7 +130,6 @@ final class LogEntryRepositoryTest extends KernelTestCase public function testGetElementHistory(): void { $category = $this->entityManager->find(Category::class, 1); - $this->assertInstanceOf(Category::class, $category); $history = $this->repo->getElementHistory($category); @@ -147,7 +141,6 @@ final class LogEntryRepositoryTest extends KernelTestCase public function testGetTimetravelDataForElement(): void { $category = $this->entityManager->find(Category::class, 1); - $this->assertInstanceOf(Category::class, $category); $data = $this->repo->getTimetravelDataForElement($category, new \DateTimeImmutable('2020-01-01')); //The data must contain only ElementChangedLogEntry diff --git a/tests/Repository/NamedDBElementRepositoryTest.php b/tests/Repository/NamedDBElementRepositoryTest.php index dc8b2a5c..117d7d0e 100644 --- a/tests/Repository/NamedDBElementRepositoryTest.php +++ b/tests/Repository/NamedDBElementRepositoryTest.php @@ -30,7 +30,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @Group DB */ -final class NamedDBElementRepositoryTest extends WebTestCase +class NamedDBElementRepositoryTest extends WebTestCase { /** * @var StructuralDBElementRepository diff --git a/tests/Repository/PartRepositoryTest.php b/tests/Repository/PartRepositoryTest.php index c2e7858a..68b75abb 100644 --- a/tests/Repository/PartRepositoryTest.php +++ b/tests/Repository/PartRepositoryTest.php @@ -60,8 +60,8 @@ final class PartRepositoryTest extends TestCase $classMetadata = new ClassMetadata(Part::class); $emMock->method('getClassMetadata')->with(Part::class)->willReturn($classMetadata); - $translatorMock = $this->createStub(TranslatorInterface::class); - $ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class); + $translatorMock = $this->createMock(TranslatorInterface::class); + $ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class); $repo = $this->getMockBuilder(PartRepository::class) ->setConstructorArgs([$emMock, $translatorMock, $ipnSuggestSettings]) @@ -120,7 +120,7 @@ final class PartRepositoryTest extends TestCase return $id; }); - $ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class); + $ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class); $ipnSuggestSettings->suggestPartDigits = 4; $ipnSuggestSettings->useDuplicateDescription = false; @@ -204,7 +204,7 @@ final class PartRepositoryTest extends TestCase return $id; }); - $ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class); + $ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class); $ipnSuggestSettings->suggestPartDigits = 4; $ipnSuggestSettings->useDuplicateDescription = false; diff --git a/tests/Repository/StructuralDBElementRepositoryTest.php b/tests/Repository/StructuralDBElementRepositoryTest.php index 16e92837..5ab8b788 100644 --- a/tests/Repository/StructuralDBElementRepositoryTest.php +++ b/tests/Repository/StructuralDBElementRepositoryTest.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace App\Tests\Repository; -use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Attachments\AttachmentType; use App\Helpers\Trees\TreeViewNode; use App\Repository\StructuralDBElementRepository; @@ -31,7 +30,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @Group DB */ -final class StructuralDBElementRepositoryTest extends WebTestCase +class StructuralDBElementRepositoryTest extends WebTestCase { /** * @var StructuralDBElementRepository @@ -109,7 +108,6 @@ final class StructuralDBElementRepositoryTest extends WebTestCase { //List all nodes that are children to Node 1 $node1 = $this->repo->find(1); - $this->assertInstanceOf(AbstractStructuralDBElement::class, $node1); $nodes = $this->repo->getFlatList($node1); $this->assertCount(3, $nodes); diff --git a/tests/Repository/UserRepositoryTest.php b/tests/Repository/UserRepositoryTest.php index 24a2d657..67a77aea 100644 --- a/tests/Repository/UserRepositoryTest.php +++ b/tests/Repository/UserRepositoryTest.php @@ -27,7 +27,7 @@ use App\Repository\UserRepository; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class UserRepositoryTest extends WebTestCase +class UserRepositoryTest extends WebTestCase { /** diff --git a/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php b/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php index 2fedf108..c9a14426 100644 --- a/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php +++ b/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php @@ -30,7 +30,7 @@ use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent; use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException; -final class EnsureSAMLUserForSAMLLoginCheckerTest extends WebTestCase +class EnsureSAMLUserForSAMLLoginCheckerTest extends WebTestCase { /** @var EnsureSAMLUserForSAMLLoginChecker */ protected $service; diff --git a/tests/Security/SamlUserFactoryTest.php b/tests/Security/SamlUserFactoryTest.php index b975ca0d..7780b4be 100644 --- a/tests/Security/SamlUserFactoryTest.php +++ b/tests/Security/SamlUserFactoryTest.php @@ -26,7 +26,7 @@ use App\Entity\UserSystem\User; use App\Security\SamlUserFactory; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class SamlUserFactoryTest extends WebTestCase +class SamlUserFactoryTest extends WebTestCase { /** @var SamlUserFactory */ diff --git a/tests/Security/UserCheckerTest.php b/tests/Security/UserCheckerTest.php index e32d5bfe..35c2e1e5 100644 --- a/tests/Security/UserCheckerTest.php +++ b/tests/Security/UserCheckerTest.php @@ -27,7 +27,7 @@ use App\Security\UserChecker; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException; -final class UserCheckerTest extends WebTestCase +class UserCheckerTest extends WebTestCase { protected $service; diff --git a/tests/Serializer/BigNumberNormalizerTest.php b/tests/Serializer/BigNumberNormalizerTest.php index 509d6352..f64347ee 100644 --- a/tests/Serializer/BigNumberNormalizerTest.php +++ b/tests/Serializer/BigNumberNormalizerTest.php @@ -29,7 +29,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Brick\Math\BigDecimal; use Brick\Math\BigNumber; -final class BigNumberNormalizerTest extends WebTestCase +class BigNumberNormalizerTest extends WebTestCase { /** @var BigNumberNormalizer */ protected $service; diff --git a/tests/Serializer/PartNormalizerTest.php b/tests/Serializer/PartNormalizerTest.php index 2f07f36d..9baff750 100644 --- a/tests/Serializer/PartNormalizerTest.php +++ b/tests/Serializer/PartNormalizerTest.php @@ -31,7 +31,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -final class PartNormalizerTest extends WebTestCase +class PartNormalizerTest extends WebTestCase { /** @var PartNormalizer */ protected DenormalizerInterface&NormalizerInterface $service; diff --git a/tests/Serializer/StructuralElementDenormalizerTest.php b/tests/Serializer/StructuralElementDenormalizerTest.php index e8e46611..31c9f0bb 100644 --- a/tests/Serializer/StructuralElementDenormalizerTest.php +++ b/tests/Serializer/StructuralElementDenormalizerTest.php @@ -27,7 +27,7 @@ use App\Entity\Parts\Category; use App\Serializer\StructuralElementDenormalizer; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class StructuralElementDenormalizerTest extends WebTestCase +class StructuralElementDenormalizerTest extends WebTestCase { /** @var StructuralElementDenormalizer */ diff --git a/tests/Serializer/StructuralElementFromNameDenormalizerTest.php b/tests/Serializer/StructuralElementFromNameDenormalizerTest.php index b4bdcdac..b344508c 100644 --- a/tests/Serializer/StructuralElementFromNameDenormalizerTest.php +++ b/tests/Serializer/StructuralElementFromNameDenormalizerTest.php @@ -26,7 +26,7 @@ use App\Entity\Parts\Category; use App\Serializer\StructuralElementFromNameDenormalizer; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class StructuralElementFromNameDenormalizerTest extends WebTestCase +class StructuralElementFromNameDenormalizerTest extends WebTestCase { /** @var StructuralElementFromNameDenormalizer */ diff --git a/tests/Serializer/StructuralElementNormalizerTest.php b/tests/Serializer/StructuralElementNormalizerTest.php index 4b335bcd..79f739fa 100644 --- a/tests/Serializer/StructuralElementNormalizerTest.php +++ b/tests/Serializer/StructuralElementNormalizerTest.php @@ -30,7 +30,7 @@ use App\Serializer\StructuralElementNormalizer; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class StructuralElementNormalizerTest extends WebTestCase +class StructuralElementNormalizerTest extends WebTestCase { /** @var StructuralElementNormalizer */ diff --git a/tests/Services/Attachments/AttachmentPathResolverTest.php b/tests/Services/Attachments/AttachmentPathResolverTest.php index b145e482..69658e13 100644 --- a/tests/Services/Attachments/AttachmentPathResolverTest.php +++ b/tests/Services/Attachments/AttachmentPathResolverTest.php @@ -28,8 +28,10 @@ use App\Services\Attachments\AttachmentPathResolver; use const DIRECTORY_SEPARATOR; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class AttachmentPathResolverTest extends WebTestCase +class AttachmentPathResolverTest extends WebTestCase { + protected string $media_path; + protected string $footprint_path; protected $projectDir_orig; protected $projectDir; /** @@ -44,8 +46,8 @@ final class AttachmentPathResolverTest extends WebTestCase $this->projectDir_orig = realpath(self::$kernel->getProjectDir()); $this->projectDir = str_replace('\\', '/', $this->projectDir_orig); - $media_path = $this->projectDir.'/public/media'; - $footprint_path = $this->projectDir.'/public/img/footprints'; + $this->media_path = $this->projectDir.'/public/media'; + $this->footprint_path = $this->projectDir.'/public/img/footprints'; $this->service = self::getContainer()->get(AttachmentPathResolver::class); } diff --git a/tests/Services/Attachments/AttachmentURLGeneratorTest.php b/tests/Services/Attachments/AttachmentURLGeneratorTest.php index 4359c1b9..e9e6d992 100644 --- a/tests/Services/Attachments/AttachmentURLGeneratorTest.php +++ b/tests/Services/Attachments/AttachmentURLGeneratorTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Attachments\AttachmentURLGenerator; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class AttachmentURLGeneratorTest extends WebTestCase +class AttachmentURLGeneratorTest extends WebTestCase { protected const PUBLIC_DIR = '/public'; diff --git a/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php b/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php index 5198ddea..80c699ac 100644 --- a/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php +++ b/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Attachments\BuiltinAttachmentsFinder; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class BuiltinAttachmentsFinderTest extends WebTestCase +class BuiltinAttachmentsFinderTest extends WebTestCase { protected static array $mock_list = [ '%FOOTPRINTS%/test/test.jpg', '%FOOTPRINTS%/test/test.png', '%FOOTPRINTS%/123.jpg', '%FOOTPRINTS%/123.jpeg', diff --git a/tests/Services/Attachments/FileTypeFilterToolsTest.php b/tests/Services/Attachments/FileTypeFilterToolsTest.php index f089feec..1b85eaeb 100644 --- a/tests/Services/Attachments/FileTypeFilterToolsTest.php +++ b/tests/Services/Attachments/FileTypeFilterToolsTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Attachments\FileTypeFilterTools; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class FileTypeFilterToolsTest extends WebTestCase +class FileTypeFilterToolsTest extends WebTestCase { protected static $service; diff --git a/tests/Services/ElementTypeNameGeneratorTest.php b/tests/Services/ElementTypeNameGeneratorTest.php index 21797137..8739dd06 100644 --- a/tests/Services/ElementTypeNameGeneratorTest.php +++ b/tests/Services/ElementTypeNameGeneratorTest.php @@ -35,7 +35,7 @@ use App\Services\Formatters\AmountFormatter; use App\Settings\SynonymSettings; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class ElementTypeNameGeneratorTest extends WebTestCase +class ElementTypeNameGeneratorTest extends WebTestCase { protected ElementTypeNameGenerator $service; private SynonymSettings $synonymSettings; diff --git a/tests/Services/ElementTypesTest.php b/tests/Services/ElementTypesTest.php index 15e5d8bb..d4fa77ff 100644 --- a/tests/Services/ElementTypesTest.php +++ b/tests/Services/ElementTypesTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\Services; use App\Entity\Parameters\CategoryParameter; @@ -28,7 +26,7 @@ use App\Exceptions\EntityNotSupportedException; use App\Services\ElementTypes; use PHPUnit\Framework\TestCase; -final class ElementTypesTest extends TestCase +class ElementTypesTest extends TestCase { public function testFromClass(): void diff --git a/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php b/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php index f5fd8334..22fa220b 100644 --- a/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php +++ b/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php @@ -28,7 +28,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; -final class EntityMergerHelperTraitTest extends KernelTestCase +class EntityMergerHelperTraitTest extends KernelTestCase { use EntityMergerHelperTrait; diff --git a/tests/Services/EntityMergers/Mergers/PartMergerTest.php b/tests/Services/EntityMergers/Mergers/PartMergerTest.php index f6a75790..7db4ddd6 100644 --- a/tests/Services/EntityMergers/Mergers/PartMergerTest.php +++ b/tests/Services/EntityMergers/Mergers/PartMergerTest.php @@ -36,7 +36,7 @@ use App\Services\EntityMergers\Mergers\PartMerger; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class PartMergerTest extends KernelTestCase +class PartMergerTest extends KernelTestCase { /** @var PartMerger|null */ diff --git a/tests/Services/Formatters/AmountFormatterTest.php b/tests/Services/Formatters/AmountFormatterTest.php index 9fdeb441..40f9b7cf 100644 --- a/tests/Services/Formatters/AmountFormatterTest.php +++ b/tests/Services/Formatters/AmountFormatterTest.php @@ -27,7 +27,7 @@ use App\Services\Formatters\AmountFormatter; use InvalidArgumentException; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class AmountFormatterTest extends WebTestCase +class AmountFormatterTest extends WebTestCase { /** * @var AmountFormatter diff --git a/tests/Services/Formatters/SIFormatterTest.php b/tests/Services/Formatters/SIFormatterTest.php index 62ca0187..79668589 100644 --- a/tests/Services/Formatters/SIFormatterTest.php +++ b/tests/Services/Formatters/SIFormatterTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Services\Formatters; use App\Services\Formatters\SIFormatter; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class SIFormatterTest extends WebTestCase +class SIFormatterTest extends WebTestCase { /** * @var SIFormatter diff --git a/tests/Services/ImportExportSystem/BOMImporterTest.php b/tests/Services/ImportExportSystem/BOMImporterTest.php index 5a9d4121..a8841f17 100644 --- a/tests/Services/ImportExportSystem/BOMImporterTest.php +++ b/tests/Services/ImportExportSystem/BOMImporterTest.php @@ -22,8 +22,6 @@ declare(strict_types=1); */ namespace App\Tests\Services\ImportExportSystem; -use App\Entity\PriceInformations\Orderdetail; -use App\Entity\Parts\Category; use App\Entity\Parts\Part; use App\Entity\Parts\Supplier; use App\Entity\ProjectSystem\Project; @@ -33,7 +31,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\File\File; -final class BOMImporterTest extends WebTestCase +class BOMImporterTest extends WebTestCase { /** @@ -393,7 +391,7 @@ final class BOMImporterTest extends WebTestCase // Check first entry $this->assertEquals('R1,R2', $bom_entries[0]->getMountnames()); - $this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON); + $this->assertEquals(2.0, $bom_entries[0]->getQuantity()); $this->assertEquals('CRCW080510K0FKEA (R_0805_2012Metric)', $bom_entries[0]->getName()); $this->assertStringContainsString('Value: 10k', $bom_entries[0]->getComment()); $this->assertStringContainsString('MPN: CRCW080510K0FKEA', $bom_entries[0]->getComment()); @@ -404,7 +402,7 @@ final class BOMImporterTest extends WebTestCase // Check second entry $this->assertEquals('C1', $bom_entries[1]->getMountnames()); - $this->assertEqualsWithDelta(1.0, $bom_entries[1]->getQuantity(), PHP_FLOAT_EPSILON); + $this->assertEquals(1.0, $bom_entries[1]->getQuantity()); $this->assertStringContainsString('LCSC SPN: C789012', $bom_entries[1]->getComment()); $this->assertStringContainsString('Mouser SPN: 80-CL21A104KOCLRNC', $bom_entries[1]->getComment()); @@ -544,7 +542,7 @@ final class BOMImporterTest extends WebTestCase $this->assertCount(1, $bom_entries); // Should merge into one entry $this->assertEquals('R1,R2', $bom_entries[0]->getMountnames()); - $this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON); + $this->assertEquals(2.0, $bom_entries[0]->getQuantity()); $this->assertEquals('CRCW080510K0FKEA', $bom_entries[0]->getName()); } @@ -632,7 +630,7 @@ final class BOMImporterTest extends WebTestCase $this->entityManager->persist($part); // Create orderdetail linking the part to a supplier SPN - $orderdetail = new Orderdetail(); + $orderdetail = new \App\Entity\PriceInformations\Orderdetail(); $orderdetail->setPart($part); $orderdetail->setSupplier($lcscSupplier); $orderdetail->setSupplierpartnr('C123456'); @@ -666,7 +664,7 @@ final class BOMImporterTest extends WebTestCase $this->assertSame($part, $bom_entries[0]->getPart()); $this->assertEquals('Test Resistor 10k 0805', $bom_entries[0]->getName()); $this->assertEquals('R1,R2', $bom_entries[0]->getMountnames()); - $this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON); + $this->assertEquals(2.0, $bom_entries[0]->getQuantity()); $this->assertStringContainsString('LCSC SPN: C123456', $bom_entries[0]->getComment()); $this->assertStringContainsString('Part-DB ID: ' . $part->getID(), $bom_entries[0]->getComment()); @@ -693,7 +691,7 @@ final class BOMImporterTest extends WebTestCase $part1->setCategory($this->getDefaultCategory($this->entityManager)); $this->entityManager->persist($part1); - $orderdetail1 = new Orderdetail(); + $orderdetail1 = new \App\Entity\PriceInformations\Orderdetail(); $orderdetail1->setPart($part1); $orderdetail1->setSupplier($lcscSupplier); $orderdetail1->setSupplierpartnr('C123456'); @@ -705,7 +703,7 @@ final class BOMImporterTest extends WebTestCase $part2->setCategory($this->getDefaultCategory($this->entityManager)); $this->entityManager->persist($part2); - $orderdetail2 = new Orderdetail(); + $orderdetail2 = new \App\Entity\PriceInformations\Orderdetail(); $orderdetail2->setPart($part2); $orderdetail2->setSupplier($mouserSupplier); $orderdetail2->setSupplierpartnr('789-CAP100NF'); @@ -796,12 +794,12 @@ final class BOMImporterTest extends WebTestCase private function getDefaultCategory(EntityManagerInterface $entityManager) { // Get the first available category or create a default one - $categoryRepo = $entityManager->getRepository(Category::class); + $categoryRepo = $entityManager->getRepository(\App\Entity\Parts\Category::class); $categories = $categoryRepo->findAll(); if (empty($categories)) { // Create a default category if none exists - $category = new Category(); + $category = new \App\Entity\Parts\Category(); $category->setName('Default Category'); $entityManager->persist($category); $entityManager->flush(); diff --git a/tests/Services/ImportExportSystem/BOMValidationServiceTest.php b/tests/Services/ImportExportSystem/BOMValidationServiceTest.php index a6c103db..055db8b4 100644 --- a/tests/Services/ImportExportSystem/BOMValidationServiceTest.php +++ b/tests/Services/ImportExportSystem/BOMValidationServiceTest.php @@ -32,16 +32,18 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** * @see \App\Services\ImportExportSystem\BOMValidationService */ -final class BOMValidationServiceTest extends WebTestCase +class BOMValidationServiceTest extends WebTestCase { private BOMValidationService $validationService; + private EntityManagerInterface $entityManager; + private TranslatorInterface $translator; protected function setUp(): void { self::bootKernel(); - $entityManager = self::getContainer()->get(EntityManagerInterface::class); - $translator = self::getContainer()->get(TranslatorInterface::class); - $this->validationService = new BOMValidationService($entityManager, $translator); + $this->entityManager = self::getContainer()->get(EntityManagerInterface::class); + $this->translator = self::getContainer()->get(TranslatorInterface::class); + $this->validationService = new BOMValidationService($this->entityManager, $this->translator); } public function testValidateBOMEntryWithValidData(): void @@ -242,7 +244,7 @@ final class BOMValidationServiceTest extends WebTestCase $this->assertTrue($result['is_valid']); $this->assertCount(1, $result['info']); - $this->assertStringContainsString('library prefix', (string) $result['info'][0]); + $this->assertStringContainsString('library prefix', $result['info'][0]); } public function testValidateBOMEntriesWithMultipleEntries(): void @@ -312,7 +314,7 @@ final class BOMValidationServiceTest extends WebTestCase $this->assertEquals(2, $stats['error_count']); $this->assertEquals(1, $stats['warning_count']); $this->assertEquals(2, $stats['info_count']); - $this->assertEqualsWithDelta(80.0, $stats['success_rate'], PHP_FLOAT_EPSILON); + $this->assertEquals(80.0, $stats['success_rate']); } public function testGetErrorMessage(): void @@ -342,6 +344,6 @@ final class BOMValidationServiceTest extends WebTestCase $message = $this->validationService->getErrorMessage($validation_result); - $this->assertSame('', $message); + $this->assertEquals('', $message); } } \ No newline at end of file diff --git a/tests/Services/ImportExportSystem/EntityExporterTest.php b/tests/Services/ImportExportSystem/EntityExporterTest.php index 8029a2d9..e9b924b1 100644 --- a/tests/Services/ImportExportSystem/EntityExporterTest.php +++ b/tests/Services/ImportExportSystem/EntityExporterTest.php @@ -28,7 +28,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; use PhpOffice\PhpSpreadsheet\IOFactory; -final class EntityExporterTest extends WebTestCase +class EntityExporterTest extends WebTestCase { /** * @var EntityExporter @@ -111,6 +111,6 @@ final class EntityExporterTest extends WebTestCase $response = $this->service->exportEntityFromRequest($entities, $request); $this->assertSame('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type')); - $this->assertStringContainsString('export_Category_simple.xlsx', (string) $response->headers->get('Content-Disposition')); + $this->assertStringContainsString('export_Category_simple.xlsx', $response->headers->get('Content-Disposition')); } } diff --git a/tests/Services/ImportExportSystem/EntityImporterTest.php b/tests/Services/ImportExportSystem/EntityImporterTest.php index b0044dda..83367f80 100644 --- a/tests/Services/ImportExportSystem/EntityImporterTest.php +++ b/tests/Services/ImportExportSystem/EntityImporterTest.php @@ -41,7 +41,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; #[Group('DB')] -final class EntityImporterTest extends WebTestCase +class EntityImporterTest extends WebTestCase { /** * @var EntityImporter diff --git a/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php index 2fd50f9a..e300e2bf 100644 --- a/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\Services\InfoProviderSystem\DTOs; -use App\Services\InfoProviderSystem\Providers\InfoProviderInterface; use App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO; use PHPUnit\Framework\TestCase; -final class BulkSearchFieldMappingDTOTest extends TestCase +class BulkSearchFieldMappingDTOTest extends TestCase { public function testProviderInstanceNormalization(): void { - $mockProvider = $this->createMock(InfoProviderInterface::class); + $mockProvider = $this->createMock(\App\Services\InfoProviderSystem\Providers\InfoProviderInterface::class); $mockProvider->method('getProviderKey')->willReturn('mock_provider'); $fieldMapping = new BulkSearchFieldMappingDTO(field: 'mpn', providers: ['provider1', $mockProvider], priority: 5); diff --git a/tests/Services/InfoProviderSystem/DTOs/BulkSearchPartResultsDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/BulkSearchPartResultsDTOTest.php index d3170d9e..09fa4973 100644 --- a/tests/Services/InfoProviderSystem/DTOs/BulkSearchPartResultsDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/BulkSearchPartResultsDTOTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\Services\InfoProviderSystem\DTOs; -use App\Entity\Parts\Part; -use App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO; use App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO; use PHPUnit\Framework\TestCase; -final class BulkSearchPartResultsDTOTest extends TestCase +class BulkSearchPartResultsDTOTest extends TestCase { public function testHasErrors(): void { - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); $this->assertFalse($test->hasErrors()); - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], ['error1']); + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], ['error1']); $this->assertTrue($test->hasErrors()); } public function testGetErrorCount(): void { - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); $this->assertCount(0, $test->errors); - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], ['error1', 'error2']); + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], ['error1', 'error2']); $this->assertCount(2, $test->errors); } public function testHasResults(): void { - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); $this->assertFalse($test->hasResults()); - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [ $this->createStub(BulkSearchPartResultDTO::class) ], []); + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [ $this->createMock(\App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO::class) ], []); $this->assertTrue($test->hasResults()); } public function testGetResultCount(): void { - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); $this->assertCount(0, $test->searchResults); - $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [ - $this->createStub(BulkSearchPartResultDTO::class), - $this->createStub(BulkSearchPartResultDTO::class) + $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [ + $this->createMock(\App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO::class), + $this->createMock(\App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO::class) ], []); $this->assertCount(2, $test->searchResults); } diff --git a/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php index f79d8ce8..ce7564da 100644 --- a/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\Services\InfoProviderSystem\DTOs; use App\Entity\Parts\Part; @@ -31,7 +29,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class BulkSearchResponseDTOTest extends KernelTestCase +class BulkSearchResponseDTOTest extends KernelTestCase { private EntityManagerInterface $entityManager; diff --git a/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php index fe563fb1..10312aca 100644 --- a/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Services\InfoProviderSystem\DTOs\FileDTO; use PHPUnit\Framework\TestCase; -final class FileDTOTest extends TestCase +class FileDTOTest extends TestCase { diff --git a/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php index 6361dc10..4c4e9bfe 100644 --- a/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Services\InfoProviderSystem\DTOs\ParameterDTO; use PHPUnit\Framework\TestCase; -final class ParameterDTOTest extends TestCase +class ParameterDTOTest extends TestCase { public static function parseValueFieldDataProvider(): \Generator diff --git a/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php index 480ff924..1c909e67 100644 --- a/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php @@ -26,7 +26,7 @@ use App\Services\InfoProviderSystem\DTOs\PriceDTO; use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO; use PHPUnit\Framework\TestCase; -final class PurchaseInfoDTOTest extends TestCase +class PurchaseInfoDTOTest extends TestCase { public function testThrowOnInvalidType(): void { diff --git a/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php index 4fbac1f3..dd516c8d 100644 --- a/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Services\InfoProviderSystem\DTOs; use App\Services\InfoProviderSystem\DTOs\SearchResultDTO; use PHPUnit\Framework\TestCase; -final class SearchResultDTOTest extends TestCase +class SearchResultDTOTest extends TestCase { public function testPreviewImageURL(): void { diff --git a/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php b/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php index 8ea6c71a..45ea9984 100644 --- a/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php +++ b/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php @@ -35,7 +35,7 @@ use PhpParser\Node\Param; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class DTOtoEntityConverterTest extends WebTestCase +class DTOtoEntityConverterTest extends WebTestCase { private ?DTOtoEntityConverter $service = null; diff --git a/tests/Services/InfoProviderSystem/ProviderRegistryTest.php b/tests/Services/InfoProviderSystem/ProviderRegistryTest.php index d3fce441..48a1847f 100644 --- a/tests/Services/InfoProviderSystem/ProviderRegistryTest.php +++ b/tests/Services/InfoProviderSystem/ProviderRegistryTest.php @@ -27,7 +27,7 @@ use App\Services\InfoProviderSystem\Providers\InfoProviderInterface; use App\Services\InfoProviderSystem\Providers\URLHandlerInfoProviderInterface; use PHPUnit\Framework\TestCase; -final class ProviderRegistryTest extends TestCase +class ProviderRegistryTest extends TestCase { /** @var InfoProviderInterface[] */ diff --git a/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php b/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php index ef446c9a..8283b7d3 100644 --- a/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php +++ b/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace App\Tests\Services\InfoProviderSystem\Providers; -use PHPUnit\Framework\Attributes\DataProvider; use App\Services\InfoProviderSystem\DTOs\PartDetailDTO; use App\Services\InfoProviderSystem\DTOs\SearchResultDTO; use App\Services\InfoProviderSystem\Providers\BuerklinProvider; @@ -19,7 +18,7 @@ use Symfony\Contracts\HttpClient\ResponseInterface; * Full behavioral test suite for BuerklinProvider. * Includes parameter parsing, compliance parsing, images, prices and batch mode. */ -final class BuerklinProviderTest extends TestCase +class BuerklinProviderTest extends TestCase { private HttpClientInterface $httpClient; private CacheItemPoolInterface $cache; @@ -109,14 +108,14 @@ final class BuerklinProviderTest extends TestCase $this->assertSame('Zener voltage', $params[0]->name); $this->assertNull($params[0]->value_text); - $this->assertEqualsWithDelta(12.0, $params[0]->value_typ, PHP_FLOAT_EPSILON); + $this->assertSame(12.0, $params[0]->value_typ); $this->assertNull($params[0]->value_min); $this->assertNull($params[0]->value_max); $this->assertSame('V', $params[0]->unit); $this->assertSame('Length', $params[1]->name); $this->assertNull($params[1]->value_text); - $this->assertEqualsWithDelta(2.9, $params[1]->value_typ, PHP_FLOAT_EPSILON); + $this->assertSame(2.9, $params[1]->value_typ); $this->assertSame('mm', $params[1]->unit); $this->assertSame('Assembly', $params[2]->name); @@ -274,70 +273,75 @@ final class BuerklinProviderTest extends TestCase $this->assertSame(['buerklin.com'], $this->provider->getHandledDomains()); } - #[DataProvider('buerklinIdFromUrlProvider')] + /** + * @dataProvider buerklinIdFromUrlProvider + */ public function testGetIDFromURLExtractsId(string $url, ?string $expected): void { $this->assertSame($expected, $this->provider->getIDFromURL($url)); } - public static function buerklinIdFromUrlProvider(): \Iterator + public static function buerklinIdFromUrlProvider(): array { - yield 'de long path' => [ - 'https://www.buerklin.com/de/p/bkl-electronic/niedervoltsteckverbinder/072341-l/40F1332/', - '40F1332', - ]; - yield 'de short path' => [ - 'https://www.buerklin.com/de/p/40F1332/', - '40F1332', - ]; - yield 'en long path' => [ - 'https://www.buerklin.com/en/p/bkl-electronic/dc-connectors/072341-l/40F1332/', - '40F1332', - ]; - yield 'en short path' => [ - 'https://www.buerklin.com/en/p/40F1332/', - '40F1332', - ]; - yield 'fragment should be ignored' => [ - 'https://www.buerklin.com/de/p/bkl-electronic/niedervoltsteckverbinder/072341-l/40F1332/#download', - '40F1332', - ]; - yield 'no trailing slash' => [ - 'https://www.buerklin.com/en/p/40F1332', - '40F1332', - ]; - yield 'query should be ignored' => [ - 'https://www.buerklin.com/en/p/40F1332/?foo=bar', - '40F1332', - ]; - yield 'query and fragment should be ignored' => [ - 'https://www.buerklin.com/en/p/40F1332/?foo=bar#download', - '40F1332', - ]; - // Negative cases - yield 'not a product url (no /p/ segment)' => [ - 'https://www.buerklin.com/de/impressum/', - null, - ]; - yield 'path contains "p" but not "/p/"' => [ - 'https://www.buerklin.com/de/help/price/', - null, - ]; - yield 'ends with /p/ (no id)' => [ - 'https://www.buerklin.com/de/p/', - null, - ]; - yield 'ends with /p (no trailing slash)' => [ - 'https://www.buerklin.com/de/p', - null, - ]; - yield 'empty string' => [ - '', - null, - ]; - yield 'not a url string' => [ - 'not a url', - null, + return [ + 'de long path' => [ + 'https://www.buerklin.com/de/p/bkl-electronic/niedervoltsteckverbinder/072341-l/40F1332/', + '40F1332', + ], + 'de short path' => [ + 'https://www.buerklin.com/de/p/40F1332/', + '40F1332', + ], + 'en long path' => [ + 'https://www.buerklin.com/en/p/bkl-electronic/dc-connectors/072341-l/40F1332/', + '40F1332', + ], + 'en short path' => [ + 'https://www.buerklin.com/en/p/40F1332/', + '40F1332', + ], + 'fragment should be ignored' => [ + 'https://www.buerklin.com/de/p/bkl-electronic/niedervoltsteckverbinder/072341-l/40F1332/#download', + '40F1332', + ], + 'no trailing slash' => [ + 'https://www.buerklin.com/en/p/40F1332', + '40F1332', + ], + 'query should be ignored' => [ + 'https://www.buerklin.com/en/p/40F1332/?foo=bar', + '40F1332', + ], + 'query and fragment should be ignored' => [ + 'https://www.buerklin.com/en/p/40F1332/?foo=bar#download', + '40F1332', + ], + + // Negative cases + 'not a product url (no /p/ segment)' => [ + 'https://www.buerklin.com/de/impressum/', + null, + ], + 'path contains "p" but not "/p/"' => [ + 'https://www.buerklin.com/de/help/price/', + null, + ], + 'ends with /p/ (no id)' => [ + 'https://www.buerklin.com/de/p/', + null, + ], + 'ends with /p (no trailing slash)' => [ + 'https://www.buerklin.com/de/p', + null, + ], + 'empty string' => [ + '', + null, + ], + 'not a url string' => [ + 'not a url', + null, + ], ]; } } diff --git a/tests/Services/InfoProviderSystem/Providers/LCSCProviderTest.php b/tests/Services/InfoProviderSystem/Providers/LCSCProviderTest.php index dc19de6b..57527f57 100644 --- a/tests/Services/InfoProviderSystem/Providers/LCSCProviderTest.php +++ b/tests/Services/InfoProviderSystem/Providers/LCSCProviderTest.php @@ -37,7 +37,7 @@ use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Contracts\HttpClient\HttpClientInterface; -final class LCSCProviderTest extends TestCase +class LCSCProviderTest extends TestCase { private LCSCSettings $settings; private LCSCProvider $provider; @@ -67,7 +67,7 @@ final class LCSCProviderTest extends TestCase public function testGetProviderKey(): void { - $this->assertSame('lcsc', $this->provider->getProviderKey()); + $this->assertEquals('lcsc', $this->provider->getProviderKey()); } public function testIsActiveWhenEnabled(): void @@ -125,8 +125,8 @@ final class LCSCProviderTest extends TestCase $this->assertIsArray($results); $this->assertCount(1, $results); $this->assertInstanceOf(PartDetailDTO::class, $results[0]); - $this->assertSame('C123456', $results[0]->provider_id); - $this->assertSame('Test Component', $results[0]->name); + $this->assertEquals('C123456', $results[0]->provider_id); + $this->assertEquals('Test Component', $results[0]->name); } public function testSearchByKeywordWithRegularTerm(): void @@ -162,8 +162,8 @@ final class LCSCProviderTest extends TestCase $this->assertIsArray($results); $this->assertCount(1, $results); $this->assertInstanceOf(PartDetailDTO::class, $results[0]); - $this->assertSame('C789012', $results[0]->provider_id); - $this->assertSame('Regular Component', $results[0]->name); + $this->assertEquals('C789012', $results[0]->provider_id); + $this->assertEquals('Regular Component', $results[0]->name); } public function testSearchByKeywordWithTipProduct(): void @@ -202,8 +202,8 @@ final class LCSCProviderTest extends TestCase $this->assertIsArray($results); $this->assertCount(1, $results); $this->assertInstanceOf(PartDetailDTO::class, $results[0]); - $this->assertSame('C555555', $results[0]->provider_id); - $this->assertSame('Tip Component', $results[0]->name); + $this->assertEquals('C555555', $results[0]->provider_id); + $this->assertEquals('Tip Component', $results[0]->name); } public function testSearchByKeywordsBatch(): void @@ -288,12 +288,12 @@ final class LCSCProviderTest extends TestCase $result = $this->provider->getDetails('C123456'); $this->assertInstanceOf(PartDetailDTO::class, $result); - $this->assertSame('C123456', $result->provider_id); - $this->assertSame('Detailed Component', $result->name); - $this->assertSame('Detailed description', $result->description); - $this->assertSame('Detailed Manufacturer', $result->manufacturer); + $this->assertEquals('C123456', $result->provider_id); + $this->assertEquals('Detailed Component', $result->name); + $this->assertEquals('Detailed description', $result->description); + $this->assertEquals('Detailed Manufacturer', $result->manufacturer); $this->assertEquals('0603', $result->footprint); - $this->assertSame('https://www.lcsc.com/product-detail/C123456.html', $result->provider_url); + $this->assertEquals('https://www.lcsc.com/product-detail/C123456.html', $result->provider_url); $this->assertCount(1, $result->images); $this->assertCount(2, $result->parameters); $this->assertCount(1, $result->vendor_infos); @@ -465,8 +465,8 @@ final class LCSCProviderTest extends TestCase $this->assertIsArray($result); $this->assertCount(1, $result); $this->assertInstanceOf(PurchaseInfoDTO::class, $result[0]); - $this->assertSame('LCSC', $result[0]->distributor_name); - $this->assertSame('C123456', $result[0]->order_number); + $this->assertEquals('LCSC', $result[0]->distributor_name); + $this->assertEquals('C123456', $result[0]->order_number); $this->assertCount(2, $result[0]->prices); } @@ -493,7 +493,7 @@ final class LCSCProviderTest extends TestCase $this->httpClient->setResponseFactory([$mockResponse]); $result = $this->provider->getDetails('C123456'); - $this->assertSame('Electronic Components -> Resistors (SMT)', $result->category); + $this->assertEquals('Electronic Components -> Resistors (SMT)', $result->category); } public function testEmptyFootprintHandling(): void diff --git a/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php b/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php index 248f1ae9..fcea7730 100644 --- a/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php +++ b/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanHelperTest.php @@ -50,7 +50,7 @@ use App\Services\LabelSystem\BarcodeScanner\EIGP114BarcodeScanResult; use App\Services\LabelSystem\BarcodeScanner\LocalBarcodeScanResult; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class BarcodeScanHelperTest extends WebTestCase +class BarcodeScanHelperTest extends WebTestCase { private ?BarcodeScanHelper $service = null; diff --git a/tests/Services/LabelSystem/BarcodeScanner/EIGP114BarcodeScanResultTest.php b/tests/Services/LabelSystem/BarcodeScanner/EIGP114BarcodeScanResultTest.php index 6d69a773..3a414997 100644 --- a/tests/Services/LabelSystem/BarcodeScanner/EIGP114BarcodeScanResultTest.php +++ b/tests/Services/LabelSystem/BarcodeScanner/EIGP114BarcodeScanResultTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Services\LabelSystem\BarcodeScanner; use App\Services\LabelSystem\BarcodeScanner\EIGP114BarcodeScanResult; use PHPUnit\Framework\TestCase; -final class EIGP114BarcodeScanResultTest extends TestCase +class EIGP114BarcodeScanResultTest extends TestCase { public function testGuessBarcodeVendor(): void diff --git a/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php b/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php index d9185735..69458734 100644 --- a/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php +++ b/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php @@ -48,7 +48,7 @@ use App\Entity\Parts\StorageLocation; use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class BarcodeContentGeneratorTest extends KernelTestCase +class BarcodeContentGeneratorTest extends KernelTestCase { private ?object $service = null; diff --git a/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php b/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php index e03221e5..d681b3b9 100644 --- a/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php +++ b/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php @@ -27,7 +27,7 @@ use App\Services\LabelSystem\Barcodes\BarcodeHelper; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class BarcodeHelperTest extends WebTestCase +class BarcodeHelperTest extends WebTestCase { protected ?BarcodeHelper $service = null; diff --git a/tests/Services/LabelSystem/LabelGeneratorTest.php b/tests/Services/LabelSystem/LabelGeneratorTest.php index 5f6d8f04..916d4317 100644 --- a/tests/Services/LabelSystem/LabelGeneratorTest.php +++ b/tests/Services/LabelSystem/LabelGeneratorTest.php @@ -51,7 +51,7 @@ use App\Entity\Parts\StorageLocation; use App\Services\LabelSystem\LabelGenerator; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class LabelGeneratorTest extends WebTestCase +class LabelGeneratorTest extends WebTestCase { /** * @var LabelGenerator diff --git a/tests/Services/LabelSystem/LabelTextReplacerTest.php b/tests/Services/LabelSystem/LabelTextReplacerTest.php index c4a140d8..346d1bab 100644 --- a/tests/Services/LabelSystem/LabelTextReplacerTest.php +++ b/tests/Services/LabelSystem/LabelTextReplacerTest.php @@ -47,7 +47,7 @@ use App\Entity\Parts\PartLot; use App\Services\LabelSystem\LabelTextReplacer; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class LabelTextReplacerTest extends WebTestCase +class LabelTextReplacerTest extends WebTestCase { /** * @var LabelTextReplacer diff --git a/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php index 584f708a..fb917b82 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php @@ -46,7 +46,7 @@ use App\Entity\Base\AbstractDBElement; use App\Services\LabelSystem\PlaceholderProviders\AbstractDBElementProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class AbstractElementProviderTest extends WebTestCase +class AbstractElementProviderTest extends WebTestCase { /** * @var AbstractDBElementProvider diff --git a/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php b/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php index 80b6b76f..d74bb215 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php @@ -46,7 +46,7 @@ use App\Entity\Parts\Part; use App\Services\LabelSystem\PlaceholderProviders\GlobalProviders; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class GlobalProvidersTest extends WebTestCase +class GlobalProvidersTest extends WebTestCase { /** * @var GlobalProviders diff --git a/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php index 88b77e8e..c5efc768 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php @@ -46,7 +46,7 @@ use App\Entity\Contracts\NamedElementInterface; use App\Services\LabelSystem\PlaceholderProviders\NamedElementProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class NamedElementProviderTest extends WebTestCase +class NamedElementProviderTest extends WebTestCase { /** * @var NamedElementProvider diff --git a/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php index 68425250..5aa8f1bd 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php @@ -49,7 +49,7 @@ use App\Entity\UserSystem\User; use App\Services\LabelSystem\PlaceholderProviders\PartLotProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class PartLotProviderTest extends WebTestCase +class PartLotProviderTest extends WebTestCase { /** * @var PartLotProvider diff --git a/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php index 9f1c74f7..7af936cd 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php @@ -53,7 +53,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; #[Group('DB')] -final class PartProviderTest extends WebTestCase +class PartProviderTest extends WebTestCase { /** * @var PartProvider @@ -62,15 +62,20 @@ final class PartProviderTest extends WebTestCase protected Part $target; + /** + * @var EntityManager + */ + protected $em; + protected function setUp(): void { self::bootKernel(); $this->service = self::getContainer()->get(PartProvider::class); $this->target = new Part(); - $em = self::getContainer()->get(EntityManagerInterface::class); + $this->em = self::getContainer()->get(EntityManagerInterface::class); - $this->target->setCategory($em->find(Category::class, 6)); - $this->target->setFootprint($em->find(Footprint::class, 6)); + $this->target->setCategory($this->em->find(Category::class, 6)); + $this->target->setFootprint($this->em->find(Footprint::class, 6)); $this->target->setManufacturer(null); $this->target->setMass(1234.2); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php index b5415131..6aa152b9 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/TimestampableElementProviderTest.php @@ -48,7 +48,7 @@ use App\Services\LabelSystem\PlaceholderProviders\TimestampableElementProvider; use DateTime; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class TimestampableElementProviderTest extends WebTestCase +class TimestampableElementProviderTest extends WebTestCase { /** * @var GlobalProviders diff --git a/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php b/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php index f10ef333..32317435 100644 --- a/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php +++ b/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php @@ -52,7 +52,7 @@ use App\Services\LabelSystem\SandboxedTwigFactory; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Twig\Sandbox\SecurityError; -final class SandboxedTwigFactoryTest extends WebTestCase +class SandboxedTwigFactoryTest extends WebTestCase { private ?SandboxedTwigFactory $service = null; diff --git a/tests/Services/LogSystem/EventCommentHelperTest.php b/tests/Services/LogSystem/EventCommentHelperTest.php index 616c1ddf..9c78d4c6 100644 --- a/tests/Services/LogSystem/EventCommentHelperTest.php +++ b/tests/Services/LogSystem/EventCommentHelperTest.php @@ -44,7 +44,7 @@ namespace App\Tests\Services\LogSystem; use App\Services\LogSystem\EventCommentHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class EventCommentHelperTest extends WebTestCase +class EventCommentHelperTest extends WebTestCase { /** * @var EventCommentHelper diff --git a/tests/Services/LogSystem/EventCommentNeededHelperTest.php b/tests/Services/LogSystem/EventCommentNeededHelperTest.php index 3ef238c5..2eb2aceb 100644 --- a/tests/Services/LogSystem/EventCommentNeededHelperTest.php +++ b/tests/Services/LogSystem/EventCommentNeededHelperTest.php @@ -28,7 +28,7 @@ use App\Settings\SystemSettings\HistorySettings; use App\Tests\SettingsTestHelper; use PHPUnit\Framework\TestCase; -final class EventCommentNeededHelperTest extends TestCase +class EventCommentNeededHelperTest extends TestCase { public function testIsCommentNeeded(): void { diff --git a/tests/Services/LogSystem/EventLoggerTest.php b/tests/Services/LogSystem/EventLoggerTest.php index 69870ac8..0dbb85a3 100644 --- a/tests/Services/LogSystem/EventLoggerTest.php +++ b/tests/Services/LogSystem/EventLoggerTest.php @@ -48,7 +48,7 @@ use App\Entity\LogSystem\UserLogoutLogEntry; use App\Services\LogSystem\EventLogger; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class EventLoggerTest extends WebTestCase +class EventLoggerTest extends WebTestCase { /** * @var EventLogger diff --git a/tests/Services/LogSystem/TimeTravelTest.php b/tests/Services/LogSystem/TimeTravelTest.php index 9b51592d..f0068778 100644 --- a/tests/Services/LogSystem/TimeTravelTest.php +++ b/tests/Services/LogSystem/TimeTravelTest.php @@ -29,7 +29,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class TimeTravelTest extends KernelTestCase +class TimeTravelTest extends KernelTestCase { private TimeTravel $service; diff --git a/tests/Services/Misc/FAIconGeneratorTest.php b/tests/Services/Misc/FAIconGeneratorTest.php index 445c167c..1aec5d02 100644 --- a/tests/Services/Misc/FAIconGeneratorTest.php +++ b/tests/Services/Misc/FAIconGeneratorTest.php @@ -26,7 +26,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Misc\FAIconGenerator; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class FAIconGeneratorTest extends WebTestCase +class FAIconGeneratorTest extends WebTestCase { /** * @var FAIconGenerator diff --git a/tests/Services/Misc/MySQLDumpXMLConverterTest.php b/tests/Services/Misc/MySQLDumpXMLConverterTest.php index a56083d8..98614b4b 100644 --- a/tests/Services/Misc/MySQLDumpXMLConverterTest.php +++ b/tests/Services/Misc/MySQLDumpXMLConverterTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Services\Misc; use App\Services\ImportExportSystem\PartKeeprImporter\MySQLDumpXMLConverter; use PHPUnit\Framework\TestCase; -final class MySQLDumpXMLConverterTest extends TestCase +class MySQLDumpXMLConverterTest extends TestCase { public function testConvertMySQLDumpXMLDataToArrayStructure(): void diff --git a/tests/Services/Misc/RangeParserTest.php b/tests/Services/Misc/RangeParserTest.php index 894034be..084ca80b 100644 --- a/tests/Services/Misc/RangeParserTest.php +++ b/tests/Services/Misc/RangeParserTest.php @@ -45,7 +45,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use App\Services\Misc\RangeParser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class RangeParserTest extends WebTestCase +class RangeParserTest extends WebTestCase { /** * @var RangeParser diff --git a/tests/Services/Parameters/ParameterExtractorTest.php b/tests/Services/Parameters/ParameterExtractorTest.php index 353a0697..d0b8fed0 100644 --- a/tests/Services/Parameters/ParameterExtractorTest.php +++ b/tests/Services/Parameters/ParameterExtractorTest.php @@ -46,7 +46,7 @@ use App\Entity\Parameters\AbstractParameter; use App\Services\Parameters\ParameterExtractor; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class ParameterExtractorTest extends WebTestCase +class ParameterExtractorTest extends WebTestCase { protected $service; diff --git a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php index de684094..b033f07e 100644 --- a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php +++ b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php @@ -18,7 +18,7 @@ class TestPartLot extends PartLot } } -final class PartLotWithdrawAddHelperTest extends WebTestCase +class PartLotWithdrawAddHelperTest extends WebTestCase { /** diff --git a/tests/Services/Parts/PartsTableActionHandlerTest.php b/tests/Services/Parts/PartsTableActionHandlerTest.php index 1772195e..c5105cd7 100644 --- a/tests/Services/Parts/PartsTableActionHandlerTest.php +++ b/tests/Services/Parts/PartsTableActionHandlerTest.php @@ -27,7 +27,7 @@ use App\Services\Parts\PartsTableActionHandler; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\RedirectResponse; -final class PartsTableActionHandlerTest extends WebTestCase +class PartsTableActionHandlerTest extends WebTestCase { private PartsTableActionHandler $service; diff --git a/tests/Services/Parts/PricedetailHelperTest.php b/tests/Services/Parts/PricedetailHelperTest.php index 08a5d6dd..5d9bd351 100644 --- a/tests/Services/Parts/PricedetailHelperTest.php +++ b/tests/Services/Parts/PricedetailHelperTest.php @@ -30,7 +30,7 @@ use App\Services\Formatters\AmountFormatter; use App\Services\Parts\PricedetailHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class PricedetailHelperTest extends WebTestCase +class PricedetailHelperTest extends WebTestCase { /** * @var AmountFormatter diff --git a/tests/Services/ProjectSystem/ProjectBuildHelperTest.php b/tests/Services/ProjectSystem/ProjectBuildHelperTest.php index fb31b51e..5009f849 100644 --- a/tests/Services/ProjectSystem/ProjectBuildHelperTest.php +++ b/tests/Services/ProjectSystem/ProjectBuildHelperTest.php @@ -29,7 +29,7 @@ use App\Entity\ProjectSystem\ProjectBOMEntry; use App\Services\ProjectSystem\ProjectBuildHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class ProjectBuildHelperTest extends WebTestCase +class ProjectBuildHelperTest extends WebTestCase { /** @var ProjectBuildHelper */ protected $service; diff --git a/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php b/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php index 894f6315..4baa7cf3 100644 --- a/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php +++ b/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php @@ -26,7 +26,7 @@ use App\Entity\ProjectSystem\Project; use App\Services\ProjectSystem\ProjectBuildPartHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class ProjectBuildPartHelperTest extends WebTestCase +class ProjectBuildPartHelperTest extends WebTestCase { /** @var ProjectBuildPartHelper */ protected $service; diff --git a/tests/Services/System/BackupManagerTest.php b/tests/Services/System/BackupManagerTest.php index f75ef8f3..145b039d 100644 --- a/tests/Services/System/BackupManagerTest.php +++ b/tests/Services/System/BackupManagerTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Services\System; use App\Services\System\BackupManager; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class BackupManagerTest extends KernelTestCase +class BackupManagerTest extends KernelTestCase { private ?BackupManager $backupManager = null; @@ -77,9 +77,9 @@ final class BackupManagerTest extends KernelTestCase $result = preg_match('/pre-update-v([\d.]+)-to-v?([\d.]+)-/', $filename, $matches); - $this->assertSame(1, $result); - $this->assertSame('2.5.1', $matches[1]); - $this->assertSame('2.6.0', $matches[2]); + $this->assertEquals(1, $result); + $this->assertEquals('2.5.1', $matches[1]); + $this->assertEquals('2.6.0', $matches[2]); } /** @@ -90,13 +90,13 @@ final class BackupManagerTest extends KernelTestCase // Without 'v' prefix on target version $filename1 = 'pre-update-v1.0.0-to-2.0.0-2024-01-30-185400.zip'; preg_match('/pre-update-v([\d.]+)-to-v?([\d.]+)-/', $filename1, $matches1); - $this->assertSame('1.0.0', $matches1[1]); - $this->assertSame('2.0.0', $matches1[2]); + $this->assertEquals('1.0.0', $matches1[1]); + $this->assertEquals('2.0.0', $matches1[2]); // With 'v' prefix on target version $filename2 = 'pre-update-v1.0.0-to-v2.0.0-2024-01-30-185400.zip'; preg_match('/pre-update-v([\d.]+)-to-v?([\d.]+)-/', $filename2, $matches2); - $this->assertSame('1.0.0', $matches2[1]); - $this->assertSame('2.0.0', $matches2[2]); + $this->assertEquals('1.0.0', $matches2[1]); + $this->assertEquals('2.0.0', $matches2[2]); } } diff --git a/tests/Services/System/UpdateExecutorTest.php b/tests/Services/System/UpdateExecutorTest.php index 48cddf8d..851d060c 100644 --- a/tests/Services/System/UpdateExecutorTest.php +++ b/tests/Services/System/UpdateExecutorTest.php @@ -25,7 +25,7 @@ namespace App\Tests\Services\System; use App\Services\System\UpdateExecutor; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -final class UpdateExecutorTest extends KernelTestCase +class UpdateExecutorTest extends KernelTestCase { private ?UpdateExecutor $updateExecutor = null; diff --git a/tests/Services/Trees/NodesListBuilderTest.php b/tests/Services/Trees/NodesListBuilderTest.php index d314114d..8f4bf23b 100644 --- a/tests/Services/Trees/NodesListBuilderTest.php +++ b/tests/Services/Trees/NodesListBuilderTest.php @@ -30,7 +30,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @Group DB */ -final class NodesListBuilderTest extends WebTestCase +class NodesListBuilderTest extends WebTestCase { protected $em; /** diff --git a/tests/Services/Trees/TreeViewGeneratorTest.php b/tests/Services/Trees/TreeViewGeneratorTest.php index 190f1068..ebec94d6 100644 --- a/tests/Services/Trees/TreeViewGeneratorTest.php +++ b/tests/Services/Trees/TreeViewGeneratorTest.php @@ -31,7 +31,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; #[Group('DB')] -final class TreeViewGeneratorTest extends WebTestCase +class TreeViewGeneratorTest extends WebTestCase { protected $em; /** diff --git a/tests/Services/UserSystem/PermissionManagerTest.php b/tests/Services/UserSystem/PermissionManagerTest.php index e6da72d4..478202f4 100644 --- a/tests/Services/UserSystem/PermissionManagerTest.php +++ b/tests/Services/UserSystem/PermissionManagerTest.php @@ -30,7 +30,7 @@ use App\Services\UserSystem\PermissionManager; use InvalidArgumentException; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class PermissionManagerTest extends WebTestCase +class PermissionManagerTest extends WebTestCase { protected ?User $user_withoutGroup = null; diff --git a/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php b/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php index 738ff649..1e41474c 100644 --- a/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php +++ b/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php @@ -39,7 +39,7 @@ class TestPermissionHolder implements HasPermissionsInterface } } -final class PermissionSchemaUpdaterTest extends WebTestCase +class PermissionSchemaUpdaterTest extends WebTestCase { /** * @var PermissionSchemaUpdater diff --git a/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php b/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php index 5a54f2f3..2b6c22d1 100644 --- a/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php +++ b/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php @@ -27,7 +27,7 @@ use App\Services\UserSystem\TFA\BackupCodeGenerator; use PHPUnit\Framework\TestCase; use RuntimeException; -final class BackupCodeGeneratorTest extends TestCase +class BackupCodeGeneratorTest extends TestCase { /** * Test if an exception is thrown if you are using a too high code length. diff --git a/tests/Services/UserSystem/TFA/BackupCodeManagerTest.php b/tests/Services/UserSystem/TFA/BackupCodeManagerTest.php index 4b1a0496..35b7f4f8 100644 --- a/tests/Services/UserSystem/TFA/BackupCodeManagerTest.php +++ b/tests/Services/UserSystem/TFA/BackupCodeManagerTest.php @@ -26,7 +26,7 @@ use App\Entity\UserSystem\User; use App\Services\UserSystem\TFA\BackupCodeManager; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class BackupCodeManagerTest extends WebTestCase +class BackupCodeManagerTest extends WebTestCase { /** * @var BackupCodeManager diff --git a/tests/Services/UserSystem/VoterHelperTest.php b/tests/Services/UserSystem/VoterHelperTest.php index 3f21c9ab..53d7ee82 100644 --- a/tests/Services/UserSystem/VoterHelperTest.php +++ b/tests/Services/UserSystem/VoterHelperTest.php @@ -34,7 +34,7 @@ use Symfony\Component\Security\Core\Authentication\Token\NullToken; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken; -final class VoterHelperTest extends KernelTestCase +class VoterHelperTest extends KernelTestCase { protected ?VoterHelper $service = null; diff --git a/tests/Settings/SynonymSettingsTest.php b/tests/Settings/SynonymSettingsTest.php index 00e5be4c..2d1407ac 100644 --- a/tests/Settings/SynonymSettingsTest.php +++ b/tests/Settings/SynonymSettingsTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\Settings; use App\Services\ElementTypes; @@ -27,7 +25,7 @@ use App\Settings\SynonymSettings; use App\Tests\SettingsTestHelper; use PHPUnit\Framework\TestCase; -final class SynonymSettingsTest extends TestCase +class SynonymSettingsTest extends TestCase { public function testGetSingularSynonymForType(): void diff --git a/tests/Twig/EntityExtensionTest.php b/tests/Twig/EntityExtensionTest.php index d206b941..18fe970b 100644 --- a/tests/Twig/EntityExtensionTest.php +++ b/tests/Twig/EntityExtensionTest.php @@ -39,7 +39,7 @@ use App\Entity\UserSystem\User; use App\Twig\EntityExtension; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class EntityExtensionTest extends WebTestCase +class EntityExtensionTest extends WebTestCase { /** @var EntityExtension */ protected $service; @@ -55,20 +55,20 @@ final class EntityExtensionTest extends WebTestCase public function testGetEntityType(): void { - $this->assertSame('part', $this->service->entityType(new Part())); - $this->assertSame('footprint', $this->service->entityType(new Footprint())); - $this->assertSame('storelocation', $this->service->entityType(new StorageLocation())); - $this->assertSame('manufacturer', $this->service->entityType(new Manufacturer())); - $this->assertSame('category', $this->service->entityType(new Category())); - $this->assertSame('device', $this->service->entityType(new Project())); - $this->assertSame('attachment', $this->service->entityType(new PartAttachment())); - $this->assertSame('supplier', $this->service->entityType(new Supplier())); - $this->assertSame('user', $this->service->entityType(new User())); - $this->assertSame('group', $this->service->entityType(new Group())); - $this->assertSame('currency', $this->service->entityType(new Currency())); - $this->assertSame('measurement_unit', $this->service->entityType(new MeasurementUnit())); - $this->assertSame('label_profile', $this->service->entityType(new LabelProfile())); - $this->assertSame('part_custom_state', $this->service->entityType(new PartCustomState())); + $this->assertSame('part', $this->service->getEntityType(new Part())); + $this->assertSame('footprint', $this->service->getEntityType(new Footprint())); + $this->assertSame('storelocation', $this->service->getEntityType(new StorageLocation())); + $this->assertSame('manufacturer', $this->service->getEntityType(new Manufacturer())); + $this->assertSame('category', $this->service->getEntityType(new Category())); + $this->assertSame('device', $this->service->getEntityType(new Project())); + $this->assertSame('attachment', $this->service->getEntityType(new PartAttachment())); + $this->assertSame('supplier', $this->service->getEntityType(new Supplier())); + $this->assertSame('user', $this->service->getEntityType(new User())); + $this->assertSame('group', $this->service->getEntityType(new Group())); + $this->assertSame('currency', $this->service->getEntityType(new Currency())); + $this->assertSame('measurement_unit', $this->service->getEntityType(new MeasurementUnit())); + $this->assertSame('label_profile', $this->service->getEntityType(new LabelProfile())); + $this->assertSame('part_custom_state', $this->service->getEntityType(new PartCustomState())); } } diff --git a/tests/Twig/TwigCoreExtensionTest.php b/tests/Twig/TwigCoreExtensionTest.php index be8ced04..1aa1f7ca 100644 --- a/tests/Twig/TwigCoreExtensionTest.php +++ b/tests/Twig/TwigCoreExtensionTest.php @@ -26,7 +26,7 @@ use App\Twig\TwigCoreExtension; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class TwigCoreExtensionTest extends WebTestCase +class TwigCoreExtensionTest extends WebTestCase { /** @var TwigCoreExtension */ protected $service; diff --git a/tests/Twig/UserExtensionTest.php b/tests/Twig/UserExtensionTest.php index f8422a2c..235d39c1 100644 --- a/tests/Twig/UserExtensionTest.php +++ b/tests/Twig/UserExtensionTest.php @@ -27,7 +27,7 @@ use App\Twig\UserExtension; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class UserExtensionTest extends WebTestCase +class UserExtensionTest extends WebTestCase { protected $service; diff --git a/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php b/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php index e4b721ca..0efcd5de 100644 --- a/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php +++ b/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php @@ -28,12 +28,15 @@ use App\Validator\Constraints\NoneOfItsChildren; use App\Validator\Constraints\NoneOfItsChildrenValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -final class NoneOfItsChildrenValidatorTest extends ConstraintValidatorTestCase +class NoneOfItsChildrenValidatorTest extends ConstraintValidatorTestCase { protected AttachmentType $root_node; protected AttachmentType $child1; + protected AttachmentType $child2; + protected AttachmentType $child3; protected AttachmentType $child1_1; + protected AttachmentType $child1_2; protected function setUp(): void { @@ -46,14 +49,14 @@ final class NoneOfItsChildrenValidatorTest extends ConstraintValidatorTestCase $this->root_node->setName('root')->setParent(null); $this->child1 = new AttachmentType(); $this->child1->setParent($this->root_node)->setName('child1'); - $child2 = new AttachmentType(); - $child2->setName('child2')->setParent($this->root_node); - $child3 = new AttachmentType(); - $child3->setName('child3')->setParent($this->root_node); + $this->child2 = new AttachmentType(); + $this->child2->setName('child2')->setParent($this->root_node); + $this->child3 = new AttachmentType(); + $this->child3->setName('child3')->setParent($this->root_node); $this->child1_1 = new AttachmentType(); $this->child1_1->setName('child1_1')->setParent($this->child1); - $child1_2 = new AttachmentType(); - $child1_2->setName('child1_2')->setParent($this->child1); + $this->child1_2 = new AttachmentType(); + $this->child1_2->setName('child1_2')->setParent($this->child1); } diff --git a/tests/Validator/Constraints/SelectableValidatorTest.php b/tests/Validator/Constraints/SelectableValidatorTest.php index 68f36f87..bc520621 100644 --- a/tests/Validator/Constraints/SelectableValidatorTest.php +++ b/tests/Validator/Constraints/SelectableValidatorTest.php @@ -29,7 +29,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Exception\UnexpectedValueException; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -final class SelectableValidatorTest extends ConstraintValidatorTestCase +class SelectableValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): SelectableValidator { diff --git a/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php b/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php index 3863d604..d9fab6cf 100644 --- a/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php +++ b/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php @@ -30,7 +30,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Exception\UnexpectedValueException; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -final class UniqueObjectCollectionValidatorTest extends ConstraintValidatorTestCase +class UniqueObjectCollectionValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): UniqueObjectCollectionValidator { diff --git a/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php b/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php index 326809df..c75754df 100644 --- a/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php +++ b/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php @@ -27,7 +27,7 @@ use App\Validator\Constraints\UrlOrBuiltinValidator; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -final class UrlOrBuiltinValidatorTest extends ConstraintValidatorTestCase +class UrlOrBuiltinValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): UrlOrBuiltinValidator diff --git a/tests/Validator/Constraints/ValidGTINValidatorTest.php b/tests/Validator/Constraints/ValidGTINValidatorTest.php index 6b01519b..f35b053a 100644 --- a/tests/Validator/Constraints/ValidGTINValidatorTest.php +++ b/tests/Validator/Constraints/ValidGTINValidatorTest.php @@ -1,7 +1,4 @@ . */ + namespace App\Tests\Validator\Constraints; -use App\Validator\Constraints\ValidGTIN; use App\Validator\Constraints\ValidGTINValidator; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -final class ValidGTINValidatorTest extends ConstraintValidatorTestCase +class ValidGTINValidatorTest extends ConstraintValidatorTestCase { public function testAllowNull(): void { - $this->validator->validate(null, new ValidGTIN()); + $this->validator->validate(null, new \App\Validator\Constraints\ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN8(): void { - $this->validator->validate('12345670', new ValidGTIN()); + $this->validator->validate('12345670', new \App\Validator\Constraints\ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN12(): void { - $this->validator->validate('123456789012', new ValidGTIN()); + $this->validator->validate('123456789012', new \App\Validator\Constraints\ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN13(): void { - $this->validator->validate('1234567890128', new ValidGTIN()); + $this->validator->validate('1234567890128', new \App\Validator\Constraints\ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN14(): void { - $this->validator->validate('12345678901231', new ValidGTIN()); + $this->validator->validate('12345678901231', new \App\Validator\Constraints\ValidGTIN()); $this->assertNoViolation(); } public function testInvalidGTIN(): void { - $this->validator->validate('1234567890123', new ValidGTIN()); + $this->validator->validate('1234567890123', new \App\Validator\Constraints\ValidGTIN()); $this->buildViolation('validator.invalid_gtin') ->assertRaised(); } diff --git a/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php b/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php index 4924f34b..6eb9270e 100644 --- a/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php +++ b/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php @@ -34,7 +34,7 @@ use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -final class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase +class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): ConstraintValidatorInterface diff --git a/tests/Validator/Constraints/ValidThemeValidatorTest.php b/tests/Validator/Constraints/ValidThemeValidatorTest.php index 50b11820..9db8f33b 100644 --- a/tests/Validator/Constraints/ValidThemeValidatorTest.php +++ b/tests/Validator/Constraints/ValidThemeValidatorTest.php @@ -27,7 +27,7 @@ use App\Validator\Constraints\ValidThemeValidator; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -final class ValidThemeValidatorTest extends ConstraintValidatorTestCase +class ValidThemeValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): ValidThemeValidator