diff --git a/config/packages/doctrine.php b/config/packages/doctrine.php index 47584ed7..e5be011f 100644 --- a/config/packages/doctrine.php +++ b/config/packages/doctrine.php @@ -20,12 +20,14 @@ 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(\Symfony\Config\DoctrineConfig $doctrine) { +return static function(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 936b447e..5a77a882 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) + ->withComposerBased(phpunit: true, symfony: true) ->withSymfonyContainerPhp(__DIR__ . '/tests/symfony-container.php') ->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml') @@ -36,8 +36,6 @@ return RectorConfig::configure() PHPUnitSetList::PHPUNIT_90, PHPUnitSetList::PHPUNIT_110, PHPUnitSetList::PHPUNIT_CODE_QUALITY, - - ]) ->withRules([ @@ -59,6 +57,9 @@ 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 @@ -67,6 +68,7 @@ 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 d9fcd7f1..b4f46a27 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -22,6 +22,7 @@ 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; @@ -151,7 +152,7 @@ final class PartController extends AbstractController $jobId = $request->query->get('jobId'); $bulkJob = null; if ($jobId) { - $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); // Verify user owns this job if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) { $bulkJob = null; @@ -172,7 +173,7 @@ final class PartController extends AbstractController throw $this->createAccessDeniedException('Invalid CSRF token'); } - $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId); if (!$bulkJob || $bulkJob->getCreatedBy() !== $this->getUser()) { throw $this->createNotFoundException('Bulk import job not found'); } @@ -338,7 +339,7 @@ final class PartController extends AbstractController $jobId = $request->query->get('jobId'); $bulkJob = null; if ($jobId) { - $bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId); + $bulkJob = $this->em->getRepository(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 4e2077c4..ad4d272f 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -147,10 +147,7 @@ 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 4e56015a..3f54e99c 100644 --- a/src/Controller/UserSettingsController.php +++ b/src/Controller/UserSettingsController.php @@ -295,10 +295,7 @@ 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 c0951d3a..9f6734e5 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, - \Doctrine\DBAL\ParameterType::INTEGER); + ParameterType::INTEGER); } //Guard condition diff --git a/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php b/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php index ecc25b4f..690448a5 100644 --- a/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php +++ b/src/EventSubscriber/UserSystem/PartUniqueIpnSubscriber.php @@ -1,5 +1,7 @@ [ //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 13e9581e..7df8985e 100644 --- a/src/Form/InfoProviderSystem/FieldToProviderMappingType.php +++ b/src/Form/InfoProviderSystem/FieldToProviderMappingType.php @@ -22,6 +22,7 @@ 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; @@ -61,7 +62,7 @@ class FieldToProviderMappingType extends AbstractType 'style' => 'width: 80px;' ], 'constraints' => [ - new \Symfony\Component\Validator\Constraints\Range(['min' => 1, 'max' => 10]), + new Range(min: 1, max: 10), ], ]); } diff --git a/src/Form/UserAdminForm.php b/src/Form/UserAdminForm.php index 69be181f..457a6e0b 100644 --- a/src/Form/UserAdminForm.php +++ b/src/Form/UserAdminForm.php @@ -177,10 +177,7 @@ 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 0c7cb169..968d8063 100644 --- a/src/Form/UserSettingsType.php +++ b/src/Form/UserSettingsType.php @@ -92,9 +92,7 @@ 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 8a91c825..abf72d74 100644 --- a/src/Services/ImportExportSystem/BOMImporter.php +++ b/src/Services/ImportExportSystem/BOMImporter.php @@ -22,6 +22,8 @@ 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; @@ -275,7 +277,7 @@ class BOMImporter $mapped_entries = []; // Collect all mapped entries for validation // Fetch suppliers once for efficiency - $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); $supplierSPNKeys = []; $suppliersByName = []; // Map supplier names to supplier objects foreach ($suppliers as $supplier) { @@ -371,7 +373,7 @@ class BOMImporter if ($supplier_spn !== null) { // Query for orderdetails with matching supplier and SPN - $orderdetail = $this->entityManager->getRepository(\App\Entity\PriceInformations\Orderdetail::class) + $orderdetail = $this->entityManager->getRepository(Orderdetail::class) ->findOneBy([ 'supplier' => $supplier, 'supplierpartnr' => $supplier_spn, @@ -535,7 +537,7 @@ class BOMImporter ]; // Add dynamic supplier fields based on available suppliers in the database - $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(Supplier::class)->findAll(); foreach ($suppliers as $supplier) { $supplierName = $supplier->getName(); $targets[$supplierName . ' SPN'] = [ @@ -570,7 +572,7 @@ class BOMImporter ]; // Add supplier-specific patterns - $suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll(); + $suppliers = $this->entityManager->getRepository(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 70feb8e6..9ed027ae 100644 --- a/src/Services/ImportExportSystem/EntityExporter.php +++ b/src/Services/ImportExportSystem/EntityExporter.php @@ -22,6 +22,7 @@ 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; @@ -177,7 +178,7 @@ class EntityExporter $colIndex = 1; foreach ($columns as $column) { - $cellCoordinate = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex) . $rowIndex; + $cellCoordinate = Coordinate::stringFromColumnIndex($colIndex) . $rowIndex; $worksheet->setCellValue($cellCoordinate, $column); $colIndex++; } diff --git a/src/Services/ImportExportSystem/EntityImporter.php b/src/Services/ImportExportSystem/EntityImporter.php index a89be9dc..7b928d6c 100644 --- a/src/Services/ImportExportSystem/EntityImporter.php +++ b/src/Services/ImportExportSystem/EntityImporter.php @@ -22,6 +22,7 @@ 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; @@ -419,14 +420,14 @@ class EntityImporter 'worksheet_title' => $worksheet->getTitle() ]); - $highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn); + $highestColumnIndex = Coordinate::columnIndexFromString($highestColumn); for ($row = 1; $row <= $highestRow; $row++) { $rowData = []; // Read all columns using numeric index for ($colIndex = 1; $colIndex <= $highestColumnIndex; $colIndex++) { - $col = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex); + $col = 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 58e9e240..3db09de3 100644 --- a/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php +++ b/src/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTO.php @@ -22,6 +22,7 @@ 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; @@ -176,7 +177,7 @@ readonly class BulkSearchResponseDTO implements \ArrayAccess, \IteratorAggregate * @param array $data * @param EntityManagerInterface $entityManager * @return BulkSearchResponseDTO - * @throws \Doctrine\ORM\Exception\ORMException + * @throws 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 aa165bfe..c2291107 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 \App\Services\InfoProviderSystem\DTOs\FileDTO[] + * @return FileDTO[] */ private function getProductImages(?array $images): array { diff --git a/src/Services/LabelSystem/SandboxedTwigFactory.php b/src/Services/LabelSystem/SandboxedTwigFactory.php index d5e09fa5..b4f1d9f6 100644 --- a/src/Services/LabelSystem/SandboxedTwigFactory.php +++ b/src/Services/LabelSystem/SandboxedTwigFactory.php @@ -70,12 +70,14 @@ 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; /** @@ -186,13 +188,18 @@ 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 8b165d5a..1ac5a2f5 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($old_data, $new_data): string + public function formatDiff(mixed $old_data, mixed $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 9bdc7f71..4946bc24 100644 --- a/src/Services/System/BackupManager.php +++ b/src/Services/System/BackupManager.php @@ -22,6 +22,8 @@ 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; @@ -334,7 +336,7 @@ readonly class BackupManager $params = $connection->getParams(); $platform = $connection->getDatabasePlatform(); - if ($platform instanceof \Doctrine\DBAL\Platforms\AbstractMySQLPlatform) { + if ($platform instanceof AbstractMySQLPlatform) { // Use mysql command to import - need to use shell to handle input redirection $mysqlCmd = 'mysql'; if (isset($params['host'])) { @@ -361,7 +363,7 @@ readonly class BackupManager if (!$process->isSuccessful()) { throw new \RuntimeException('MySQL import failed: ' . $process->getErrorOutput()); } - } elseif ($platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform) { + } elseif ($platform instanceof 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 9f81abe6..3d5ec611 100644 --- a/src/Twig/AttachmentExtension.php +++ b/src/Twig/AttachmentExtension.php @@ -25,22 +25,34 @@ 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 class AttachmentExtension extends AbstractExtension +final readonly class AttachmentExtension { - public function __construct(protected AttachmentURLGenerator $attachmentURLGenerator, protected FAIconGenerator $FAIconGenerator) + public function __construct(private AttachmentURLGenerator $attachmentURLGenerator, private FAIconGenerator $FAIconGenerator) { } - public function getFunctions(): array + /** + * 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 { - 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 ?? '')), - ]; + 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 ?? ''); } } diff --git a/src/Twig/BarcodeExtension.php b/src/Twig/BarcodeExtension.php index ae1973e3..25c0d78e 100644 --- a/src/Twig/BarcodeExtension.php +++ b/src/Twig/BarcodeExtension.php @@ -23,19 +23,14 @@ declare(strict_types=1); namespace App\Twig; use Com\Tecnick\Barcode\Barcode; -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; +use Twig\Attribute\AsTwigFunction; -final class BarcodeExtension extends AbstractExtension +final class BarcodeExtension { - 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)), - ]; - } - + /** + * Generates a barcode in SVG format for the given content and type. + */ + #[AsTwigFunction('barcode_svg')] 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 427a39b5..bff21eb8 100644 --- a/src/Twig/EntityExtension.php +++ b/src/Twig/EntityExtension.php @@ -41,6 +41,9 @@ 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; @@ -48,61 +51,27 @@ use Twig\TwigTest; /** * @see \App\Tests\Twig\EntityExtensionTest */ -final class EntityExtension extends AbstractExtension +final readonly class EntityExtension { - public function __construct(protected EntityURLGenerator $entityURLGenerator, protected TreeViewGenerator $treeBuilder, private readonly ElementTypeNameGenerator $nameGenerator) + public function __construct(private EntityURLGenerator $entityURLGenerator, private TreeViewGenerator $treeBuilder, private ElementTypeNameGenerator $nameGenerator) { } - public function getTests(): array + /** + * Checks if the given variable is an entity (instance of AbstractDBElement). + */ + #[AsTwigTest("entity")] + public function entityTest(mixed $var): bool { - return [ - /* Checks if the given variable is an entitity (instance of AbstractDBElement) */ - new TwigTest('entity', static fn($var) => $var instanceof AbstractDBElement), - ]; + return $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)), - /* 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 + /** + * Returns a string representation of the given entity + */ + #[AsTwigFunction("entity_type")] + public function entityType(object $entity): ?string { $map = [ Part::class => 'part', @@ -129,4 +98,69 @@ final class EntityExtension extends AbstractExtension 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 46313aaf..b91b7e11 100644 --- a/src/Twig/FormatExtension.php +++ b/src/Twig/FormatExtension.php @@ -29,35 +29,28 @@ use App\Services\Formatters\MarkdownParser; use App\Services\Formatters\MoneyFormatter; use App\Services\Formatters\SIFormatter; use Brick\Math\BigDecimal; -use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; +use Twig\Attribute\AsTwigFilter; -final class FormatExtension extends AbstractExtension +final readonly class FormatExtension { - public function __construct(protected MarkdownParser $markdownParser, protected MoneyFormatter $moneyFormatter, protected SIFormatter $siformatter, protected AmountFormatter $amountFormatter) + public function __construct(private MarkdownParser $markdownParser, private MoneyFormatter $moneyFormatter, private SIFormatter $siformatter, private AmountFormatter $amountFormatter) { } - public function getFilters(): array + /** + * 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 { - 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)), - ]; + return $this->markdownParser->markForRendering($markdown, $inline_mode); } - public function formatCurrency($amount, ?Currency $currency = null, int $decimals = 5): string + /** + * 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 { if ($amount instanceof BigDecimal) { $amount = (string) $amount; @@ -66,19 +59,22 @@ final class FormatExtension extends AbstractExtension return $this->moneyFormatter->format($amount, $currency, $decimals); } - public function siFormat($value, $unit, $decimals = 2, bool $show_all_digits = false): string + /** + * 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 { return $this->siformatter->format($value, $unit, $decimals); } - public function amountFormat($value, ?MeasurementUnit $unit, array $options = []): string + #[AsTwigFilter("format_amount")] + public function amountFormat(float|int|string $value, ?MeasurementUnit $unit, array $options = []): string { return $this->amountFormatter->format($value, $unit, $options); } - /** - * @param $bytes - */ + #[AsTwigFilter("format_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 a963b778..54dbf93a 100644 --- a/src/Twig/InfoProviderExtension.php +++ b/src/Twig/InfoProviderExtension.php @@ -23,31 +23,25 @@ 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; -class InfoProviderExtension extends AbstractExtension +final readonly class InfoProviderExtension { public function __construct( - private readonly ProviderRegistry $providerRegistry + private 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 */ - private function getInfoProvider(string $key): ?InfoProviderInterface + #[AsTwigFunction(name: 'info_provider')] + public function getInfoProvider(string $key): ?InfoProviderInterface { try { return $this->providerRegistry->getProviderByKey($key); @@ -61,7 +55,8 @@ class InfoProviderExtension extends AbstractExtension * @param string $key * @return string|null */ - private function getInfoProviderName(string $key): ?string + #[AsTwigFunction(name: 'info_provider_label')] + public function getInfoProviderName(string $key): ?string { try { return $this->providerRegistry->getProviderByKey($key)->getProviderInfo()['name']; @@ -69,4 +64,4 @@ class InfoProviderExtension extends AbstractExtension return null; } } -} \ No newline at end of file +} diff --git a/src/Twig/LogExtension.php b/src/Twig/LogExtension.php index 34dad988..738a24c2 100644 --- a/src/Twig/LogExtension.php +++ b/src/Twig/LogExtension.php @@ -25,21 +25,26 @@ 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 class LogExtension extends AbstractExtension +final readonly class LogExtension { - public function __construct(private readonly LogDataFormatter $logDataFormatter, private readonly LogDiffFormatter $logDiffFormatter) + public function __construct(private LogDataFormatter $logDataFormatter, private LogDiffFormatter $logDiffFormatter) { } - public function getFunctions(): array + #[AsTwigFunction(name: 'format_log_data', isSafe: ['html'])] + public function formatLogData(mixed $data, AbstractLogEntry $logEntry, string $fieldName): string { - 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']]), - ]; + 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); } } diff --git a/src/Twig/MiscExtension.php b/src/Twig/MiscExtension.php index 8b6ebc68..390ad084 100644 --- a/src/Twig/MiscExtension.php +++ b/src/Twig/MiscExtension.php @@ -22,6 +22,7 @@ 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; @@ -31,23 +32,14 @@ use Twig\TwigFunction; use App\Services\LogSystem\EventCommentNeededHelper; use Twig\Extension\AbstractExtension; -final class MiscExtension extends AbstractExtension +final readonly class MiscExtension { - public function __construct(private readonly EventCommentNeededHelper $eventCommentNeededHelper) + public function __construct(private EventCommentNeededHelper $eventCommentNeededHelper) { } - 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 + #[AsTwigFunction(name: 'event_comment_needed')] + public function evenCommentNeeded(string|EventCommentType $operation_type): bool { if (is_string($operation_type)) { $operation_type = EventCommentType::from($operation_type); @@ -63,7 +55,8 @@ final class MiscExtension extends AbstractExtension * @return string|null * @throws \ReflectionException */ - private function settingsIcon(string|object $objectOrClass): ?string + #[AsTwigFunction(name: 'settings_icon')] + public function settingsIcon(string|object $objectOrClass): ?string { //If the given object is a proxy, then get the real object if (is_a($objectOrClass, SettingsProxyInterface::class)) { @@ -82,6 +75,7 @@ final class MiscExtension extends AbstractExtension * @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 7b2b58f8..ceb4ce82 100644 --- a/src/Twig/TwigCoreExtension.php +++ b/src/Twig/TwigCoreExtension.php @@ -22,7 +22,11 @@ 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; @@ -32,58 +36,54 @@ 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 class TwigCoreExtension extends AbstractExtension +final readonly class TwigCoreExtension { - private readonly ObjectNormalizer $objectNormalizer; + private NormalizerInterface $objectNormalizer; public function __construct() { $this->objectNormalizer = new ObjectNormalizer(); } - public function getFunctions(): array + /** + * 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 { - return [ - /* Returns the enum cases as values */ - new TwigFunction('enum_cases', $this->getEnumCases(...)), - ]; - } + if (!class_exists($instance) && !interface_exists($instance) && !enum_exists($instance)) { + throw new \InvalidArgumentException(sprintf('The given class/interface/enum "%s" does not exist!', $instance)); + } - 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), - ]; + return $var instanceof $instance; } /** - * @param string $enum_class - * @phpstan-param class-string $enum_class + * 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 */ - public function getEnumCases(string $enum_class): array + #[AsTwigTest("object")] + public function testObject(mixed $var): bool { - if (!enum_exists($enum_class)) { - throw new \InvalidArgumentException(sprintf('The given class "%s" is not an enum!', $enum_class)); - } - - /** @noinspection PhpUndefinedMethodInspection */ - return ($enum_class)::cases(); + return is_object($var); } - public function getFilters(): array + /** + * 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 [ - /* Converts the given object to an array representation of the public/accessible properties */ - new TwigFilter('to_array', fn($object) => $this->toArray($object)), - ]; + 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 ee3bb16c..7ec7897b 100644 --- a/src/Twig/UpdateExtension.php +++ b/src/Twig/UpdateExtension.php @@ -23,6 +23,7 @@ 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; @@ -31,26 +32,18 @@ use Twig\TwigFunction; /** * Twig extension for update-related functions. */ -final class UpdateExtension extends AbstractExtension +final readonly class UpdateExtension { - public function __construct(private readonly UpdateAvailableFacade $updateAvailableManager, - private readonly Security $security) + public function __construct(private UpdateAvailableFacade $updateAvailableManager, + private 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 @@ -64,6 +57,7 @@ final class UpdateExtension extends AbstractExtension /** * Get the latest available version string. */ + #[AsTwigFunction(name: 'get_latest_version')] public function getLatestVersion(): string { return $this->updateAvailableManager->getLatestVersionString(); @@ -72,6 +66,7 @@ final class UpdateExtension extends AbstractExtension /** * 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 5045257a..81ff0857 100644 --- a/src/Twig/UserExtension.php +++ b/src/Twig/UserExtension.php @@ -41,51 +41,24 @@ declare(strict_types=1); namespace App\Twig; -use App\Entity\Base\AbstractDBElement; +use Twig\Attribute\AsTwigFilter; +use Twig\Attribute\AsTwigFunction; 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 class UserExtension extends AbstractExtension +final readonly class UserExtension { - private readonly LogEntryRepository $repo; - public function __construct(EntityManagerInterface $em, - private readonly Security $security, - private readonly UrlGeneratorInterface $urlGenerator) + public function __construct( + private Security $security, + private 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(...)), - ]; } /** @@ -93,6 +66,7 @@ final class UserExtension extends AbstractExtension * 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(); @@ -107,11 +81,13 @@ final class UserExtension extends AbstractExtension 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)) { @@ -124,6 +100,7 @@ final class UserExtension extends AbstractExtension /** * 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 new file mode 100644 index 00000000..1dcc6706 --- /dev/null +++ b/src/Twig/UserRepoExtension.php @@ -0,0 +1,57 @@ +. + */ + +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 ca32f9ef..652f2bcd 100644 --- a/src/Validator/Constraints/UniquePartIpnConstraint.php +++ b/src/Validator/Constraints/UniquePartIpnConstraint.php @@ -1,5 +1,7 @@ - {% if entity is instanceof("App\\Entity\\Parts\\Storelocation") %} + {% if entity is instanceof("App\\Entity\\Parts\\StorageLocation") %} {{ 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 b7caa873..a7bba3d6 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; -class APIDocsAvailabilityTest extends WebTestCase +final 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 a78b0594..803a1819 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; -class APITokenAuthenticationTest extends ApiTestCase +final class APITokenAuthenticationTest extends ApiTestCase { public function testUnauthenticated(): void { diff --git a/tests/API/Endpoints/ApiTokenEnpointTest.php b/tests/API/Endpoints/ApiTokenEnpointTest.php index 99340182..f21716bd 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; -class ApiTokenEnpointTest extends AuthenticatedApiTestCase +final class ApiTokenEnpointTest extends AuthenticatedApiTestCase { public function testGetCurrentToken(): void { diff --git a/tests/API/Endpoints/AttachmentTypeEndpointTest.php b/tests/API/Endpoints/AttachmentTypeEndpointTest.php index f90f3d94..fb5770d5 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; -class AttachmentTypeEndpointTest extends CrudEndpointTestCase +final class AttachmentTypeEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/AttachmentsEndpointTest.php b/tests/API/Endpoints/AttachmentsEndpointTest.php index 8f4d7e77..999b7ad3 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; -class AttachmentsEndpointTest extends AuthenticatedApiTestCase +final class AttachmentsEndpointTest extends AuthenticatedApiTestCase { public function testGetCollection(): void { diff --git a/tests/API/Endpoints/CategoryEndpointTest.php b/tests/API/Endpoints/CategoryEndpointTest.php index 68f4fd2d..5f54d1dd 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; -class CategoryEndpointTest extends CrudEndpointTestCase +final class CategoryEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/CurrencyEndpointTest.php b/tests/API/Endpoints/CurrencyEndpointTest.php index a463daeb..a9f36633 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; -class CurrencyEndpointTest extends CrudEndpointTestCase +final class CurrencyEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/FootprintsEndpointTest.php b/tests/API/Endpoints/FootprintsEndpointTest.php index f3f359a2..fd6374f9 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; -class FootprintsEndpointTest extends CrudEndpointTestCase +final class FootprintsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/InfoEndpointTest.php b/tests/API/Endpoints/InfoEndpointTest.php index 09f02e8a..6e996c0c 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; -class InfoEndpointTest extends AuthenticatedApiTestCase +final class InfoEndpointTest extends AuthenticatedApiTestCase { public function testGetInfo(): void { diff --git a/tests/API/Endpoints/ManufacturersEndpointTest.php b/tests/API/Endpoints/ManufacturersEndpointTest.php index 482ec98d..80447c93 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; -class ManufacturersEndpointTest extends CrudEndpointTestCase +final class ManufacturersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/MeasurementUnitsEndpointTest.php b/tests/API/Endpoints/MeasurementUnitsEndpointTest.php index db7341db..d659fb1c 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; -class MeasurementUnitsEndpointTest extends CrudEndpointTestCase +final class MeasurementUnitsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/OrderdetailsEndpointTest.php b/tests/API/Endpoints/OrderdetailsEndpointTest.php index 92823103..d7d132d9 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; -class OrderdetailsEndpointTest extends CrudEndpointTestCase +final class OrderdetailsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/ParametersEndpointTest.php b/tests/API/Endpoints/ParametersEndpointTest.php index 733df59a..323fc7b8 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; -class ParametersEndpointTest extends CrudEndpointTestCase +final class ParametersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartAssociationsEndpointTest.php b/tests/API/Endpoints/PartAssociationsEndpointTest.php index 62408dbb..7ac81ff6 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; -class PartAssociationsEndpointTest extends CrudEndpointTestCase +final class PartAssociationsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartCustomStateEndpointTest.php b/tests/API/Endpoints/PartCustomStateEndpointTest.php index ac353d9c..8d1253f3 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; -class PartCustomStateEndpointTest extends CrudEndpointTestCase +final class PartCustomStateEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartEndpointTest.php b/tests/API/Endpoints/PartEndpointTest.php index 9406fc78..8d66d362 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; -class PartEndpointTest extends CrudEndpointTestCase +final class PartEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PartLotsEndpointTest.php b/tests/API/Endpoints/PartLotsEndpointTest.php index 38aa6b18..70f1f9ab 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; -class PartLotsEndpointTest extends CrudEndpointTestCase +final class PartLotsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/PricedetailsEndpointTest.php b/tests/API/Endpoints/PricedetailsEndpointTest.php index 8895365f..5661c0c7 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; -class PricedetailsEndpointTest extends CrudEndpointTestCase +final class PricedetailsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/ProjectBOMEntriesEndpointTest.php b/tests/API/Endpoints/ProjectBOMEntriesEndpointTest.php index cafb57dc..10dbf747 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; -class ProjectBOMEntriesEndpointTest extends CrudEndpointTestCase +final class ProjectBOMEntriesEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/ProjectsEndpointTest.php b/tests/API/Endpoints/ProjectsEndpointTest.php index 9daf584a..ea9cc6b4 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; -class ProjectsEndpointTest extends CrudEndpointTestCase +final class ProjectsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/StorageLocationsEndpointTest.php b/tests/API/Endpoints/StorageLocationsEndpointTest.php index 8d9641c4..11947e71 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; -class StorageLocationsEndpointTest extends CrudEndpointTestCase +final class StorageLocationsEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/SuppliersEndpointTest.php b/tests/API/Endpoints/SuppliersEndpointTest.php index 1941f849..bbb64e90 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; -class SuppliersEndpointTest extends CrudEndpointTestCase +final class SuppliersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/API/Endpoints/UsersEndpointTest.php b/tests/API/Endpoints/UsersEndpointTest.php index 0f075a7c..e6e18930 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; -class UsersEndpointTest extends CrudEndpointTestCase +final class UsersEndpointTest extends CrudEndpointTestCase { protected function getBasePath(): string diff --git a/tests/ApplicationAvailabilityFunctionalTest.php b/tests/ApplicationAvailabilityFunctionalTest.php index d5bced49..c7449411 100644 --- a/tests/ApplicationAvailabilityFunctionalTest.php +++ b/tests/ApplicationAvailabilityFunctionalTest.php @@ -32,7 +32,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ #[Group('DB')] #[Group('slow')] -class ApplicationAvailabilityFunctionalTest extends WebTestCase +final 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 599a6f69..90e6583d 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')] -class AttachmentTypeController extends AbstractAdminController +final 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 c1bac093..5d8396e7 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')] -class CategoryController extends AbstractAdminController +final 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 21f94a29..4ebd82e2 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')] -class CurrencyController extends AbstractAdminController +final 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 7d617ba8..2643d3f1 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')] -class FootprintController extends AbstractAdminController +final 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 838d872e..d407701a 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; -class LabelProfileController extends AbstractAdminController +final 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 c2666f72..2a5ed386 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')] -class ManufacturerController extends AbstractAdminController +final 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 351f4e51..c15d4af4 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')] -class MeasurementUnitController extends AbstractAdminController +final 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 3e87dfe2..77d1127c 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')] -class PartCustomStateControllerTest extends AbstractAdminController +final 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 1de4bf52..d7bec069 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')] -class ProjectController extends AbstractAdminController +final 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 fee06c67..f19a5f6a 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')] -class StorelocationController extends AbstractAdminController +final 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 3549eb4b..1e1d720a 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')] -class SupplierController extends AbstractAdminController +final 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 8961d23b..ec3629fe 100644 --- a/tests/Controller/BulkInfoProviderImportControllerTest.php +++ b/tests/Controller/BulkInfoProviderImportControllerTest.php @@ -22,6 +22,8 @@ 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; @@ -36,7 +38,7 @@ use Symfony\Component\HttpFoundation\Response; #[Group("slow")] #[Group("DB")] -class BulkInfoProviderImportControllerTest extends WebTestCase +final class BulkInfoProviderImportControllerTest extends WebTestCase { public function testStep1WithoutIds(): void { @@ -174,8 +176,8 @@ class BulkInfoProviderImportControllerTest extends WebTestCase // Verify the template rendered the source_field and source_keyword correctly $content = $client->getResponse()->getContent(); - $this->assertStringContainsString('test_field', $content); - $this->assertStringContainsString('test_keyword', $content); + $this->assertStringContainsString('test_field', (string) $content); + $this->assertStringContainsString('test_keyword', (string) $content); // Clean up - find by ID to avoid detached entity issues $jobId = $job->getId(); @@ -607,7 +609,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase } $this->assertResponseStatusCodeSame(Response::HTTP_OK); - $this->assertStringContainsString('Bulk Info Provider Import', $client->getResponse()->getContent()); + $this->assertStringContainsString('Bulk Info Provider Import', (string) $client->getResponse()->getContent()); } public function testStep1FormSubmissionWithErrors(): void @@ -630,7 +632,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase } $this->assertResponseStatusCodeSame(Response::HTTP_OK); - $this->assertStringContainsString('Bulk Info Provider Import', $client->getResponse()->getContent()); + $this->assertStringContainsString('Bulk Info Provider Import', (string) $client->getResponse()->getContent()); } public function testBulkInfoProviderServiceKeywordExtraction(): void @@ -647,18 +649,18 @@ class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can extract keywords from parts - $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(BulkInfoProviderService::class); // Create field mappings to verify the service works $fieldMappings = [ - new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('name', ['test'], 1), - new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('mpn', ['test'], 2) + new BulkSearchFieldMappingDTO('name', ['test'], 1), + new 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(\App\Services\InfoProviderSystem\DTOs\BulkSearchResponseDTO::class, $result); + $this->assertInstanceOf(BulkSearchResponseDTO::class, $result); } catch (\RuntimeException $e) { $this->assertStringContainsString('No search results found', $e->getMessage()); } @@ -725,12 +727,12 @@ class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can handle supplier part number fields - $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(BulkInfoProviderService::class); // Create field mappings with supplier SPN field mapping $fieldMappings = [ - new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('invalid_field', ['test'], 1), - new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('test_supplier_spn', ['test'], 2) + new BulkSearchFieldMappingDTO('invalid_field', ['test'], 1), + new BulkSearchFieldMappingDTO('test_supplier_spn', ['test'], 2) ]; // The service should be able to process the request and throw an exception when no results are found @@ -756,11 +758,11 @@ class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can handle batch processing - $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(BulkInfoProviderService::class); // Create field mappings with multiple keywords $fieldMappings = [ - new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('empty', ['test'], 1) + new BulkSearchFieldMappingDTO('empty', ['test'], 1) ]; // The service should be able to process the request and throw an exception when no results are found @@ -786,7 +788,7 @@ class BulkInfoProviderImportControllerTest extends WebTestCase } // Test that the service can handle prefetch details - $bulkService = $client->getContainer()->get(\App\Services\InfoProviderSystem\BulkInfoProviderService::class); + $bulkService = $client->getContainer()->get(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 a66cb8a4..9d33512a 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; -class KiCadApiControllerTest extends WebTestCase +final 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 8c9f3729..c15bdd51 100644 --- a/tests/Controller/PartControllerTest.php +++ b/tests/Controller/PartControllerTest.php @@ -38,7 +38,7 @@ use Symfony\Component\HttpFoundation\Response; #[Group("slow")] #[Group("DB")] -class PartControllerTest extends WebTestCase +final class PartControllerTest extends WebTestCase { public function testShowPart(): void { diff --git a/tests/Controller/RedirectControllerTest.php b/tests/Controller/RedirectControllerTest.php index ac2776e5..420b0f49 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')] -class RedirectControllerTest extends WebTestCase +final class RedirectControllerTest extends WebTestCase { protected EntityManagerInterface $em; protected UserRepository $userRepo; diff --git a/tests/Controller/ScanControllerTest.php b/tests/Controller/ScanControllerTest.php index 98992e09..b504cd29 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; -class ScanControllerTest extends WebTestCase +final class ScanControllerTest extends WebTestCase { private ?KernelBrowser $client = null; diff --git a/tests/DataTables/Filters/CompoundFilterTraitTest.php b/tests/DataTables/Filters/CompoundFilterTraitTest.php index 93f3c1e1..d9bf20b0 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; -class CompoundFilterTraitTest extends TestCase +final class CompoundFilterTraitTest extends TestCase { public function testFindAllChildFiltersEmpty(): void @@ -49,9 +49,9 @@ class CompoundFilterTraitTest extends TestCase public function testFindAllChildFilters(): void { - $f1 = $this->createMock(FilterInterface::class); - $f2 = $this->createMock(FilterInterface::class); - $f3 = $this->createMock(FilterInterface::class); + $f1 = $this->createStub(FilterInterface::class); + $f2 = $this->createStub(FilterInterface::class); + $f3 = $this->createStub(FilterInterface::class); $filter = new class($f1, $f2, $f3, null) { use CompoundFilterTrait; @@ -108,7 +108,7 @@ class CompoundFilterTraitTest extends TestCase } }; - $qb = $this->createMock(QueryBuilder::class); + $qb = $this->createStub(QueryBuilder::class); $filter->_applyAllChildFilters($qb); } diff --git a/tests/DataTables/Filters/Constraints/FilterTraitTest.php b/tests/DataTables/Filters/Constraints/FilterTraitTest.php index e1e459d5..a7493dcf 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; -class FilterTraitTest extends TestCase +final 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 816a8035..333b9af5 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; -class BulkImportJobStatusConstraintTest extends TestCase +final class BulkImportJobStatusConstraintTest extends TestCase { private BulkImportJobStatusConstraint $constraint; private QueryBuilder $queryBuilder; @@ -46,7 +46,7 @@ class BulkImportJobStatusConstraintTest extends TestCase public function testConstructor(): void { - $this->assertEquals([], $this->constraint->getValue()); + $this->assertSame([], $this->constraint->getValue()); $this->assertEmpty($this->constraint->getOperator()); $this->assertFalse($this->constraint->isEnabled()); } @@ -56,7 +56,7 @@ class BulkImportJobStatusConstraintTest extends TestCase $values = ['pending', 'in_progress']; $this->constraint->setValue($values); - $this->assertEquals($values, $this->constraint->getValue()); + $this->assertSame($values, $this->constraint->getValue()); } public function testGetAndSetOperator(): void @@ -64,7 +64,7 @@ class BulkImportJobStatusConstraintTest extends TestCase $operator = 'ANY'; $this->constraint->setOperator($operator); - $this->assertEquals($operator, $this->constraint->getOperator()); + $this->assertSame($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 bc110eda..e2b37287 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; -class BulkImportPartStatusConstraintTest extends TestCase +final class BulkImportPartStatusConstraintTest extends TestCase { private BulkImportPartStatusConstraint $constraint; private QueryBuilder $queryBuilder; @@ -46,7 +46,7 @@ class BulkImportPartStatusConstraintTest extends TestCase public function testConstructor(): void { - $this->assertEquals([], $this->constraint->getValue()); + $this->assertSame([], $this->constraint->getValue()); $this->assertEmpty($this->constraint->getOperator()); $this->assertFalse($this->constraint->isEnabled()); } @@ -56,7 +56,7 @@ class BulkImportPartStatusConstraintTest extends TestCase $values = ['pending', 'completed', 'skipped']; $this->constraint->setValue($values); - $this->assertEquals($values, $this->constraint->getValue()); + $this->assertSame($values, $this->constraint->getValue()); } public function testGetAndSetOperator(): void @@ -64,7 +64,7 @@ class BulkImportPartStatusConstraintTest extends TestCase $operator = 'ANY'; $this->constraint->setOperator($operator); - $this->assertEquals($operator, $this->constraint->getOperator()); + $this->assertSame($operator, $this->constraint->getOperator()); } public function testIsEnabledWithEmptyValues(): void @@ -294,6 +294,6 @@ class BulkImportPartStatusConstraintTest extends TestCase $this->constraint->apply($this->queryBuilder); - $this->assertEquals($statusValues, $this->constraint->getValue()); + $this->assertSame($statusValues, $this->constraint->getValue()); } } diff --git a/tests/DatatablesAvailabilityTest.php b/tests/DatatablesAvailabilityTest.php index dad61be3..1447da73 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; -class DatatablesAvailabilityTest extends WebTestCase +final 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 67410f76..aa5e4da1 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; -class SQLiteRegexMiddlewareTest extends TestCase +final class SQLiteRegexMiddlewareTest extends TestCase { public static function regexpDataProvider(): \Generator diff --git a/tests/Entity/Attachments/AttachmentTest.php b/tests/Entity/Attachments/AttachmentTest.php index 35222d63..ca55424c 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; -class AttachmentTest extends TestCase +final class AttachmentTest extends TestCase { public function testEmptyState(): void { diff --git a/tests/Entity/Attachments/AttachmentTypeTest.php b/tests/Entity/Attachments/AttachmentTypeTest.php index ea80db11..c966d23f 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; -class AttachmentTypeTest extends TestCase +final class AttachmentTypeTest extends TestCase { public function testEmptyState(): void { diff --git a/tests/Entity/Base/AbstractStructuralDBElementTest.php b/tests/Entity/Base/AbstractStructuralDBElementTest.php index 3f8157ad..90a7dee2 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. */ -class AbstractStructuralDBElementTest extends TestCase +final class AbstractStructuralDBElementTest extends TestCase { protected AttachmentType $root; protected AttachmentType $child1; diff --git a/tests/Entity/BulkImportJobStatusTest.php b/tests/Entity/BulkImportJobStatusTest.php index e8b4a977..c38d62e2 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; -class BulkImportJobStatusTest extends TestCase +final class BulkImportJobStatusTest extends TestCase { public function testEnumValues(): void { diff --git a/tests/Entity/BulkInfoProviderImportJobPartTest.php b/tests/Entity/BulkInfoProviderImportJobPartTest.php index dd9600dd..94b05637 100644 --- a/tests/Entity/BulkInfoProviderImportJobPartTest.php +++ b/tests/Entity/BulkInfoProviderImportJobPartTest.php @@ -28,32 +28,25 @@ use App\Entity\InfoProviderSystem\BulkInfoProviderImportJobPart; use App\Entity\Parts\Part; use PHPUnit\Framework\TestCase; -class BulkInfoProviderImportJobPartTest extends TestCase +final class BulkInfoProviderImportJobPartTest extends TestCase { - private BulkInfoProviderImportJob $job; - private Part $part; private BulkInfoProviderImportJobPart $jobPart; protected function setUp(): void { - $this->job = $this->createMock(BulkInfoProviderImportJob::class); - $this->part = $this->createMock(Part::class); - - $this->jobPart = new BulkInfoProviderImportJobPart($this->job, $this->part); + $this->jobPart = new BulkInfoProviderImportJobPart($this->createStub(BulkInfoProviderImportJob::class), $this->createStub(Part::class)); } public function testConstructor(): void { - $this->assertSame($this->job, $this->jobPart->getJob()); - $this->assertSame($this->part, $this->jobPart->getPart()); - $this->assertEquals(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); + $this->assertSame(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); $this->assertNull($this->jobPart->getReason()); $this->assertNull($this->jobPart->getCompletedAt()); } public function testGetAndSetJob(): void { - $newJob = $this->createMock(BulkInfoProviderImportJob::class); + $newJob = $this->createStub(BulkInfoProviderImportJob::class); $result = $this->jobPart->setJob($newJob); @@ -63,7 +56,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase public function testGetAndSetPart(): void { - $newPart = $this->createMock(Part::class); + $newPart = $this->createStub(Part::class); $result = $this->jobPart->setPart($newPart); @@ -76,7 +69,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->setStatus(BulkImportPartStatus::COMPLETED); $this->assertSame($this->jobPart, $result); - $this->assertEquals(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); + $this->assertSame(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); } public function testGetAndSetReason(): void @@ -86,7 +79,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->setReason($reason); $this->assertSame($this->jobPart, $result); - $this->assertEquals($reason, $this->jobPart->getReason()); + $this->assertSame($reason, $this->jobPart->getReason()); } public function testGetAndSetCompletedAt(): void @@ -108,7 +101,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase $afterTime = new \DateTimeImmutable(); $this->assertSame($this->jobPart, $result); - $this->assertEquals(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); + $this->assertSame(BulkImportPartStatus::COMPLETED, $this->jobPart->getStatus()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); $this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt()); $this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt()); @@ -124,8 +117,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase $afterTime = new \DateTimeImmutable(); $this->assertSame($this->jobPart, $result); - $this->assertEquals(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); - $this->assertEquals($reason, $this->jobPart->getReason()); + $this->assertSame(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); + $this->assertSame($reason, $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); $this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt()); $this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt()); @@ -136,8 +129,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->markAsSkipped(); $this->assertSame($this->jobPart, $result); - $this->assertEquals(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); - $this->assertEquals('', $this->jobPart->getReason()); + $this->assertSame(BulkImportPartStatus::SKIPPED, $this->jobPart->getStatus()); + $this->assertSame('', $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); } @@ -151,8 +144,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase $afterTime = new \DateTimeImmutable(); $this->assertSame($this->jobPart, $result); - $this->assertEquals(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); - $this->assertEquals($reason, $this->jobPart->getReason()); + $this->assertSame(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); + $this->assertSame($reason, $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); $this->assertGreaterThanOrEqual($beforeTime, $this->jobPart->getCompletedAt()); $this->assertLessThanOrEqual($afterTime, $this->jobPart->getCompletedAt()); @@ -163,8 +156,8 @@ class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->markAsFailed(); $this->assertSame($this->jobPart, $result); - $this->assertEquals(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); - $this->assertEquals('', $this->jobPart->getReason()); + $this->assertSame(BulkImportPartStatus::FAILED, $this->jobPart->getStatus()); + $this->assertSame('', $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); } @@ -176,7 +169,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase $result = $this->jobPart->markAsPending(); $this->assertSame($this->jobPart, $result); - $this->assertEquals(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); + $this->assertSame(BulkImportPartStatus::PENDING, $this->jobPart->getStatus()); $this->assertNull($this->jobPart->getReason()); $this->assertNull($this->jobPart->getCompletedAt()); } @@ -281,7 +274,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase // After marking as skipped, should have reason and completion time $this->jobPart->markAsSkipped('Skipped reason'); - $this->assertEquals('Skipped reason', $this->jobPart->getReason()); + $this->assertSame('Skipped reason', $this->jobPart->getReason()); $this->assertInstanceOf(\DateTimeImmutable::class, $this->jobPart->getCompletedAt()); // After marking as pending, reason and completion time should be cleared @@ -291,7 +284,7 @@ class BulkInfoProviderImportJobPartTest extends TestCase // After marking as failed, should have reason and completion time $this->jobPart->markAsFailed('Failed reason'); - $this->assertEquals('Failed reason', $this->jobPart->getReason()); + $this->assertSame('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 c9841ac4..d1a854cd 100644 --- a/tests/Entity/BulkInfoProviderImportJobTest.php +++ b/tests/Entity/BulkInfoProviderImportJobTest.php @@ -22,6 +22,8 @@ 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; @@ -31,7 +33,7 @@ use App\Services\InfoProviderSystem\DTOs\BulkSearchResponseDTO; use App\Services\InfoProviderSystem\DTOs\SearchResultDTO; use PHPUnit\Framework\TestCase; -class BulkInfoProviderImportJobTest extends TestCase +final class BulkInfoProviderImportJobTest extends TestCase { private BulkInfoProviderImportJob $job; private User $user; @@ -45,9 +47,9 @@ class BulkInfoProviderImportJobTest extends TestCase $this->job->setCreatedBy($this->user); } - private function createMockPart(int $id): \App\Entity\Parts\Part + private function createMockPart(int $id): Part { - $part = $this->createMock(\App\Entity\Parts\Part::class); + $part = $this->createMock(Part::class); $part->method('getId')->willReturn($id); $part->method('getName')->willReturn("Test Part {$id}"); return $part; @@ -58,7 +60,7 @@ class BulkInfoProviderImportJobTest extends TestCase $job = new BulkInfoProviderImportJob(); $this->assertInstanceOf(\DateTimeImmutable::class, $job->getCreatedAt()); - $this->assertEquals(BulkImportJobStatus::PENDING, $job->getStatus()); + $this->assertSame(BulkImportJobStatus::PENDING, $job->getStatus()); $this->assertEmpty($job->getPartIds()); $this->assertEmpty($job->getFieldMappings()); $this->assertEmpty($job->getSearchResultsRaw()); @@ -70,14 +72,14 @@ class BulkInfoProviderImportJobTest extends TestCase public function testBasicGettersSetters(): void { $this->job->setName('Test Job'); - $this->assertEquals('Test Job', $this->job->getName()); + $this->assertSame('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->assertEquals([1, 2, 3], $this->job->getPartIds()); + $this->assertSame([1, 2, 3], $this->job->getPartIds()); $fieldMappings = [new BulkSearchFieldMappingDTO(field: 'field1', providers: ['provider1', 'provider2'])]; $this->job->setFieldMappings($fieldMappings); @@ -98,24 +100,24 @@ class BulkInfoProviderImportJobTest extends TestCase $this->assertFalse($this->job->isStopped()); $this->job->markAsInProgress(); - $this->assertEquals(BulkImportJobStatus::IN_PROGRESS, $this->job->getStatus()); + $this->assertSame(BulkImportJobStatus::IN_PROGRESS, $this->job->getStatus()); $this->assertTrue($this->job->isInProgress()); $this->assertFalse($this->job->isPending()); $this->job->markAsCompleted(); - $this->assertEquals(BulkImportJobStatus::COMPLETED, $this->job->getStatus()); + $this->assertSame(BulkImportJobStatus::COMPLETED, $this->job->getStatus()); $this->assertTrue($this->job->isCompleted()); $this->assertNotNull($this->job->getCompletedAt()); $job2 = new BulkInfoProviderImportJob(); $job2->markAsFailed(); - $this->assertEquals(BulkImportJobStatus::FAILED, $job2->getStatus()); + $this->assertSame(BulkImportJobStatus::FAILED, $job2->getStatus()); $this->assertTrue($job2->isFailed()); $this->assertNotNull($job2->getCompletedAt()); $job3 = new BulkInfoProviderImportJob(); $job3->markAsStopped(); - $this->assertEquals(BulkImportJobStatus::STOPPED, $job3->getStatus()); + $this->assertSame(BulkImportJobStatus::STOPPED, $job3->getStatus()); $this->assertTrue($job3->isStopped()); $this->assertNotNull($job3->getCompletedAt()); } @@ -139,7 +141,7 @@ class BulkInfoProviderImportJobTest extends TestCase public function testPartCount(): void { - $this->assertEquals(0, $this->job->getPartCount()); + $this->assertSame(0, $this->job->getPartCount()); // Test with actual parts - setPartIds doesn't actually add parts $parts = [ @@ -152,31 +154,31 @@ class BulkInfoProviderImportJobTest extends TestCase foreach ($parts as $part) { $this->job->addPart($part); } - $this->assertEquals(5, $this->job->getPartCount()); + $this->assertSame(5, $this->job->getPartCount()); } public function testResultCount(): void { - $this->assertEquals(0, $this->job->getResultCount()); + $this->assertSame(0, $this->job->getResultCount()); $searchResults = new BulkSearchResponseDTO([ - new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO( + new BulkSearchPartResultsDTO( part: $this->createMockPart(1), searchResults: [new BulkSearchPartResultDTO(searchResult: new SearchResultDTO(provider_key: 'dummy', provider_id: '1234', name: 'Part 1', description: 'A part'))] ), - new \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO( + new 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 \App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultsDTO( + new BulkSearchPartResultsDTO( part: $this->createMockPart(3), searchResults: [] ) ]); $this->job->setSearchResults($searchResults); - $this->assertEquals(3, $this->job->getResultCount()); + $this->assertSame(3, $this->job->getResultCount()); } public function testPartProgressTracking(): void @@ -222,21 +224,21 @@ class BulkInfoProviderImportJobTest extends TestCase $this->job->addPart($part); } - $this->assertEquals(0, $this->job->getCompletedPartsCount()); - $this->assertEquals(0, $this->job->getSkippedPartsCount()); + $this->assertSame(0, $this->job->getCompletedPartsCount()); + $this->assertSame(0, $this->job->getSkippedPartsCount()); $this->job->markPartAsCompleted(1); $this->job->markPartAsCompleted(2); $this->job->markPartAsSkipped(3, 'Error'); - $this->assertEquals(2, $this->job->getCompletedPartsCount()); - $this->assertEquals(1, $this->job->getSkippedPartsCount()); + $this->assertSame(2, $this->job->getCompletedPartsCount()); + $this->assertSame(1, $this->job->getSkippedPartsCount()); } public function testProgressPercentage(): void { $emptyJob = new BulkInfoProviderImportJob(); - $this->assertEquals(100.0, $emptyJob->getProgressPercentage()); + $this->assertEqualsWithDelta(100.0, $emptyJob->getProgressPercentage(), PHP_FLOAT_EPSILON); // Test with actual parts - setPartIds doesn't actually add parts $parts = [ @@ -250,18 +252,18 @@ class BulkInfoProviderImportJobTest extends TestCase $this->job->addPart($part); } - $this->assertEquals(0.0, $this->job->getProgressPercentage()); + $this->assertEqualsWithDelta(0.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); $this->job->markPartAsCompleted(1); $this->job->markPartAsCompleted(2); - $this->assertEquals(40.0, $this->job->getProgressPercentage()); + $this->assertEqualsWithDelta(40.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); $this->job->markPartAsSkipped(3, 'Error'); - $this->assertEquals(60.0, $this->job->getProgressPercentage()); + $this->assertEqualsWithDelta(60.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); $this->job->markPartAsCompleted(4); $this->job->markPartAsCompleted(5); - $this->assertEquals(100.0, $this->job->getProgressPercentage()); + $this->assertEqualsWithDelta(100.0, $this->job->getProgressPercentage(), PHP_FLOAT_EPSILON); } public function testIsAllPartsCompleted(): void @@ -301,8 +303,8 @@ class BulkInfoProviderImportJobTest extends TestCase $this->job->addPart($part); } - $this->assertEquals('info_providers.bulk_import.job_name_template', $this->job->getDisplayNameKey()); - $this->assertEquals(['%count%' => 3], $this->job->getDisplayNameParams()); + $this->assertSame('info_providers.bulk_import.job_name_template', $this->job->getDisplayNameKey()); + $this->assertSame(['%count%' => 3], $this->job->getDisplayNameParams()); } public function testFormattedTimestamp(): void diff --git a/tests/Entity/LogSystem/AbstractLogEntryTest.php b/tests/Entity/LogSystem/AbstractLogEntryTest.php index 3f223693..d99b8e73 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; -class AbstractLogEntryTest extends TestCase +final class AbstractLogEntryTest extends TestCase { public function testSetGetTarget(): void { diff --git a/tests/Entity/LogSystem/LogLevelTest.php b/tests/Entity/LogSystem/LogLevelTest.php index 402942e1..0125b0cd 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; -class LogLevelTest extends TestCase +final class LogLevelTest extends TestCase { public function testToPSR3LevelString(): void diff --git a/tests/Entity/LogSystem/LogTargetTypeTest.php b/tests/Entity/LogSystem/LogTargetTypeTest.php index 46682496..06e2ead1 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; -class LogTargetTypeTest extends TestCase +final class LogTargetTypeTest extends TestCase { public function testToClass(): void diff --git a/tests/Entity/Parameters/PartParameterTest.php b/tests/Entity/Parameters/PartParameterTest.php index 64550eee..6a07468e 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; -class PartParameterTest extends TestCase +final class PartParameterTest extends TestCase { public static function valueWithUnitDataProvider(): \Iterator { diff --git a/tests/Entity/Parts/InfoProviderReferenceTest.php b/tests/Entity/Parts/InfoProviderReferenceTest.php index a1a8d5de..dcc6a43c 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; -class InfoProviderReferenceTest extends TestCase +final class InfoProviderReferenceTest extends TestCase { public function testNoProvider(): void { diff --git a/tests/Entity/Parts/PartAssociationTest.php b/tests/Entity/Parts/PartAssociationTest.php index e002846e..25487d1f 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; -class PartAssociationTest extends TestCase +final class PartAssociationTest extends TestCase { public function testGetTypeTranslationKey(): void diff --git a/tests/Entity/Parts/PartLotTest.php b/tests/Entity/Parts/PartLotTest.php index 30687b72..10cc80b9 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; -class PartLotTest extends TestCase +final class PartLotTest extends TestCase { public function testIsExpired(): void { diff --git a/tests/Entity/Parts/PartTest.php b/tests/Entity/Parts/PartTest.php index c1ae8935..e855c340 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; -class PartTest extends TestCase +final class PartTest extends TestCase { public function testAddRemovePartLot(): void { diff --git a/tests/Entity/PriceSystem/CurrencyTest.php b/tests/Entity/PriceSystem/CurrencyTest.php index 0058d501..018092e5 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; -class CurrencyTest extends TestCase +final class CurrencyTest extends TestCase { public function testGetInverseExchangeRate(): void { diff --git a/tests/Entity/PriceSystem/OrderdetailTest.php b/tests/Entity/PriceSystem/OrderdetailTest.php index df86ab34..2becb74e 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; -class OrderdetailTest extends TestCase +final class OrderdetailTest extends TestCase { public function testAddRemovePricdetails(): void { diff --git a/tests/Entity/PriceSystem/PricedetailTest.php b/tests/Entity/PriceSystem/PricedetailTest.php index 8a3cf328..effe6fd6 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; -class PricedetailTest extends TestCase +final class PricedetailTest extends TestCase { public function testGetPricePerUnit(): void { diff --git a/tests/Entity/UserSystem/ApiTokenTypeTest.php b/tests/Entity/UserSystem/ApiTokenTypeTest.php index a8e520f1..7a4506ba 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; -class ApiTokenTypeTest extends TestCase +final class ApiTokenTypeTest extends TestCase { public function testGetTokenPrefix(): void diff --git a/tests/Entity/UserSystem/PermissionDataTest.php b/tests/Entity/UserSystem/PermissionDataTest.php index 4fd8c5ce..3d250a81 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; -class PermissionDataTest extends TestCase +final class PermissionDataTest extends TestCase { public function testGetSetIs(): void diff --git a/tests/Entity/UserSystem/UserTest.php b/tests/Entity/UserSystem/UserTest.php index a4349e1d..12797ad1 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; -class UserTest extends TestCase +final class UserTest extends TestCase { public function testGetFullName(): void { diff --git a/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php b/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php index 4099f0ee..c4c9f04b 100644 --- a/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php +++ b/tests/EnvVarProcessors/AddSlashEnvVarProcessorTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\EnvVarProcessors; use App\EnvVarProcessors\AddSlashEnvVarProcessor; use PHPUnit\Framework\TestCase; -class AddSlashEnvVarProcessorTest extends TestCase +final class AddSlashEnvVarProcessorTest extends TestCase { protected AddSlashEnvVarProcessor $processor; diff --git a/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php b/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php index 58573ae6..3a35c670 100644 --- a/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php +++ b/tests/EventListener/RegisterSynonymsAsTranslationParametersTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\EventListener; use App\EventListener\RegisterSynonymsAsTranslationParametersListener; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -class RegisterSynonymsAsTranslationParametersTest extends KernelTestCase +final class RegisterSynonymsAsTranslationParametersTest extends KernelTestCase { private RegisterSynonymsAsTranslationParametersListener $listener; diff --git a/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php b/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php index 0eaf931c..3d2089e1 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; -class PasswordChangeNeededSubscriberTest extends TestCase +final class PasswordChangeNeededSubscriberTest extends TestCase { public function testTFARedirectNeeded(): void { diff --git a/tests/Exceptions/TwigModeExceptionTest.php b/tests/Exceptions/TwigModeExceptionTest.php index 686a87a2..09468291 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; -class TwigModeExceptionTest extends KernelTestCase +final class TwigModeExceptionTest extends KernelTestCase { private string $projectPath; diff --git a/tests/Form/InfoProviderSystem/GlobalFieldMappingTypeTest.php b/tests/Form/InfoProviderSystem/GlobalFieldMappingTypeTest.php index 89e362e4..07106505 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")] -class GlobalFieldMappingTypeTest extends KernelTestCase +final class GlobalFieldMappingTypeTest extends KernelTestCase { private FormFactoryInterface $formFactory; diff --git a/tests/Helpers/BBCodeToMarkdownConverterTest.php b/tests/Helpers/BBCodeToMarkdownConverterTest.php index 9506cba4..07fca505 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; -class BBCodeToMarkdownConverterTest extends TestCase +final class BBCodeToMarkdownConverterTest extends TestCase { protected BBCodeToMarkdownConverter $converter; diff --git a/tests/Helpers/IPAnonymizerTest.php b/tests/Helpers/IPAnonymizerTest.php index e16368eb..7efd27ac 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; -class IPAnonymizerTest extends TestCase +final class IPAnonymizerTest extends TestCase { public static function anonymizeDataProvider(): \Generator diff --git a/tests/Helpers/Projects/ProjectBuildRequestTest.php b/tests/Helpers/Projects/ProjectBuildRequestTest.php index 1158d89a..c1fd1498 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; -class ProjectBuildRequestTest extends TestCase +final class ProjectBuildRequestTest extends TestCase { /** @var Project */ diff --git a/tests/Helpers/TreeViewNodeTest.php b/tests/Helpers/TreeViewNodeTest.php index 9005651d..b1179f6c 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; -class TreeViewNodeTest extends TestCase +final class TreeViewNodeTest extends TestCase { /** * @var TreeViewNode diff --git a/tests/Helpers/TrinaryLogicHelperTest.php b/tests/Helpers/TrinaryLogicHelperTest.php index 3082571b..4b8c9f01 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; -class TrinaryLogicHelperTest extends TestCase +final class TrinaryLogicHelperTest extends TestCase { public function testNot() diff --git a/tests/Repository/AttachmentContainingDBElementRepositoryTest.php b/tests/Repository/AttachmentContainingDBElementRepositoryTest.php index f61750d9..38aca071 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; -class AttachmentContainingDBElementRepositoryTest extends KernelTestCase +final class AttachmentContainingDBElementRepositoryTest extends KernelTestCase { private EntityManagerInterface $entityManager; diff --git a/tests/Repository/DBElementRepositoryTest.php b/tests/Repository/DBElementRepositoryTest.php index 05ede7e2..5f1ac0e1 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; -class DBElementRepositoryTest extends KernelTestCase +final class DBElementRepositoryTest extends KernelTestCase { private EntityManagerInterface $entityManager; diff --git a/tests/Repository/LogEntryRepositoryTest.php b/tests/Repository/LogEntryRepositoryTest.php index f6cc991d..46093a9e 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; -class LogEntryRepositoryTest extends KernelTestCase +final class LogEntryRepositoryTest extends KernelTestCase { private EntityManagerInterface $entityManager; @@ -75,6 +75,7 @@ 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); @@ -83,6 +84,7 @@ 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); } @@ -92,6 +94,7 @@ 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); @@ -100,6 +103,7 @@ 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); } @@ -119,6 +123,7 @@ 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())); @@ -130,6 +135,7 @@ 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); @@ -141,6 +147,7 @@ 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 117d7d0e..dc8b2a5c 100644 --- a/tests/Repository/NamedDBElementRepositoryTest.php +++ b/tests/Repository/NamedDBElementRepositoryTest.php @@ -30,7 +30,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @Group DB */ -class NamedDBElementRepositoryTest extends WebTestCase +final class NamedDBElementRepositoryTest extends WebTestCase { /** * @var StructuralDBElementRepository diff --git a/tests/Repository/PartRepositoryTest.php b/tests/Repository/PartRepositoryTest.php index 68b75abb..c2e7858a 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->createMock(TranslatorInterface::class); - $ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class); + $translatorMock = $this->createStub(TranslatorInterface::class); + $ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class); $repo = $this->getMockBuilder(PartRepository::class) ->setConstructorArgs([$emMock, $translatorMock, $ipnSuggestSettings]) @@ -120,7 +120,7 @@ final class PartRepositoryTest extends TestCase return $id; }); - $ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class); + $ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class); $ipnSuggestSettings->suggestPartDigits = 4; $ipnSuggestSettings->useDuplicateDescription = false; @@ -204,7 +204,7 @@ final class PartRepositoryTest extends TestCase return $id; }); - $ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class); + $ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class); $ipnSuggestSettings->suggestPartDigits = 4; $ipnSuggestSettings->useDuplicateDescription = false; diff --git a/tests/Repository/StructuralDBElementRepositoryTest.php b/tests/Repository/StructuralDBElementRepositoryTest.php index 5ab8b788..16e92837 100644 --- a/tests/Repository/StructuralDBElementRepositoryTest.php +++ b/tests/Repository/StructuralDBElementRepositoryTest.php @@ -22,6 +22,7 @@ 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; @@ -30,7 +31,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @Group DB */ -class StructuralDBElementRepositoryTest extends WebTestCase +final class StructuralDBElementRepositoryTest extends WebTestCase { /** * @var StructuralDBElementRepository @@ -108,6 +109,7 @@ 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 67a77aea..24a2d657 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; -class UserRepositoryTest extends WebTestCase +final class UserRepositoryTest extends WebTestCase { /** diff --git a/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php b/tests/Security/EnsureSAMLUserForSAMLLoginCheckerTest.php index c9a14426..2fedf108 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; -class EnsureSAMLUserForSAMLLoginCheckerTest extends WebTestCase +final class EnsureSAMLUserForSAMLLoginCheckerTest extends WebTestCase { /** @var EnsureSAMLUserForSAMLLoginChecker */ protected $service; diff --git a/tests/Security/SamlUserFactoryTest.php b/tests/Security/SamlUserFactoryTest.php index 7780b4be..b975ca0d 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; -class SamlUserFactoryTest extends WebTestCase +final class SamlUserFactoryTest extends WebTestCase { /** @var SamlUserFactory */ diff --git a/tests/Security/UserCheckerTest.php b/tests/Security/UserCheckerTest.php index 35c2e1e5..e32d5bfe 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; -class UserCheckerTest extends WebTestCase +final class UserCheckerTest extends WebTestCase { protected $service; diff --git a/tests/Serializer/BigNumberNormalizerTest.php b/tests/Serializer/BigNumberNormalizerTest.php index f64347ee..509d6352 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; -class BigNumberNormalizerTest extends WebTestCase +final class BigNumberNormalizerTest extends WebTestCase { /** @var BigNumberNormalizer */ protected $service; diff --git a/tests/Serializer/PartNormalizerTest.php b/tests/Serializer/PartNormalizerTest.php index 9baff750..2f07f36d 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; -class PartNormalizerTest extends WebTestCase +final class PartNormalizerTest extends WebTestCase { /** @var PartNormalizer */ protected DenormalizerInterface&NormalizerInterface $service; diff --git a/tests/Serializer/StructuralElementDenormalizerTest.php b/tests/Serializer/StructuralElementDenormalizerTest.php index 31c9f0bb..e8e46611 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; -class StructuralElementDenormalizerTest extends WebTestCase +final class StructuralElementDenormalizerTest extends WebTestCase { /** @var StructuralElementDenormalizer */ diff --git a/tests/Serializer/StructuralElementFromNameDenormalizerTest.php b/tests/Serializer/StructuralElementFromNameDenormalizerTest.php index b344508c..b4bdcdac 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; -class StructuralElementFromNameDenormalizerTest extends WebTestCase +final class StructuralElementFromNameDenormalizerTest extends WebTestCase { /** @var StructuralElementFromNameDenormalizer */ diff --git a/tests/Serializer/StructuralElementNormalizerTest.php b/tests/Serializer/StructuralElementNormalizerTest.php index 79f739fa..4b335bcd 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; -class StructuralElementNormalizerTest extends WebTestCase +final class StructuralElementNormalizerTest extends WebTestCase { /** @var StructuralElementNormalizer */ diff --git a/tests/Services/Attachments/AttachmentPathResolverTest.php b/tests/Services/Attachments/AttachmentPathResolverTest.php index 69658e13..b145e482 100644 --- a/tests/Services/Attachments/AttachmentPathResolverTest.php +++ b/tests/Services/Attachments/AttachmentPathResolverTest.php @@ -28,10 +28,8 @@ use App\Services\Attachments\AttachmentPathResolver; use const DIRECTORY_SEPARATOR; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -class AttachmentPathResolverTest extends WebTestCase +final class AttachmentPathResolverTest extends WebTestCase { - protected string $media_path; - protected string $footprint_path; protected $projectDir_orig; protected $projectDir; /** @@ -46,8 +44,8 @@ class AttachmentPathResolverTest extends WebTestCase $this->projectDir_orig = realpath(self::$kernel->getProjectDir()); $this->projectDir = str_replace('\\', '/', $this->projectDir_orig); - $this->media_path = $this->projectDir.'/public/media'; - $this->footprint_path = $this->projectDir.'/public/img/footprints'; + $media_path = $this->projectDir.'/public/media'; + $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 e9e6d992..4359c1b9 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; -class AttachmentURLGeneratorTest extends WebTestCase +final class AttachmentURLGeneratorTest extends WebTestCase { protected const PUBLIC_DIR = '/public'; diff --git a/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php b/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php index 80c699ac..5198ddea 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; -class BuiltinAttachmentsFinderTest extends WebTestCase +final 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 1b85eaeb..f089feec 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; -class FileTypeFilterToolsTest extends WebTestCase +final class FileTypeFilterToolsTest extends WebTestCase { protected static $service; diff --git a/tests/Services/ElementTypeNameGeneratorTest.php b/tests/Services/ElementTypeNameGeneratorTest.php index 8739dd06..21797137 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; -class ElementTypeNameGeneratorTest extends WebTestCase +final class ElementTypeNameGeneratorTest extends WebTestCase { protected ElementTypeNameGenerator $service; private SynonymSettings $synonymSettings; diff --git a/tests/Services/ElementTypesTest.php b/tests/Services/ElementTypesTest.php index d4fa77ff..15e5d8bb 100644 --- a/tests/Services/ElementTypesTest.php +++ b/tests/Services/ElementTypesTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services; use App\Entity\Parameters\CategoryParameter; @@ -26,7 +28,7 @@ use App\Exceptions\EntityNotSupportedException; use App\Services\ElementTypes; use PHPUnit\Framework\TestCase; -class ElementTypesTest extends TestCase +final 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 22fa220b..f5fd8334 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; -class EntityMergerHelperTraitTest extends KernelTestCase +final class EntityMergerHelperTraitTest extends KernelTestCase { use EntityMergerHelperTrait; diff --git a/tests/Services/EntityMergers/Mergers/PartMergerTest.php b/tests/Services/EntityMergers/Mergers/PartMergerTest.php index 7db4ddd6..f6a75790 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; -class PartMergerTest extends KernelTestCase +final class PartMergerTest extends KernelTestCase { /** @var PartMerger|null */ diff --git a/tests/Services/Formatters/AmountFormatterTest.php b/tests/Services/Formatters/AmountFormatterTest.php index 40f9b7cf..9fdeb441 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; -class AmountFormatterTest extends WebTestCase +final class AmountFormatterTest extends WebTestCase { /** * @var AmountFormatter diff --git a/tests/Services/Formatters/SIFormatterTest.php b/tests/Services/Formatters/SIFormatterTest.php index 79668589..62ca0187 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; -class SIFormatterTest extends WebTestCase +final class SIFormatterTest extends WebTestCase { /** * @var SIFormatter diff --git a/tests/Services/ImportExportSystem/BOMImporterTest.php b/tests/Services/ImportExportSystem/BOMImporterTest.php index a8841f17..5a9d4121 100644 --- a/tests/Services/ImportExportSystem/BOMImporterTest.php +++ b/tests/Services/ImportExportSystem/BOMImporterTest.php @@ -22,6 +22,8 @@ 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; @@ -31,7 +33,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\File\File; -class BOMImporterTest extends WebTestCase +final class BOMImporterTest extends WebTestCase { /** @@ -391,7 +393,7 @@ class BOMImporterTest extends WebTestCase // Check first entry $this->assertEquals('R1,R2', $bom_entries[0]->getMountnames()); - $this->assertEquals(2.0, $bom_entries[0]->getQuantity()); + $this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON); $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()); @@ -402,7 +404,7 @@ class BOMImporterTest extends WebTestCase // Check second entry $this->assertEquals('C1', $bom_entries[1]->getMountnames()); - $this->assertEquals(1.0, $bom_entries[1]->getQuantity()); + $this->assertEqualsWithDelta(1.0, $bom_entries[1]->getQuantity(), PHP_FLOAT_EPSILON); $this->assertStringContainsString('LCSC SPN: C789012', $bom_entries[1]->getComment()); $this->assertStringContainsString('Mouser SPN: 80-CL21A104KOCLRNC', $bom_entries[1]->getComment()); @@ -542,7 +544,7 @@ class BOMImporterTest extends WebTestCase $this->assertCount(1, $bom_entries); // Should merge into one entry $this->assertEquals('R1,R2', $bom_entries[0]->getMountnames()); - $this->assertEquals(2.0, $bom_entries[0]->getQuantity()); + $this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON); $this->assertEquals('CRCW080510K0FKEA', $bom_entries[0]->getName()); } @@ -630,7 +632,7 @@ class BOMImporterTest extends WebTestCase $this->entityManager->persist($part); // Create orderdetail linking the part to a supplier SPN - $orderdetail = new \App\Entity\PriceInformations\Orderdetail(); + $orderdetail = new Orderdetail(); $orderdetail->setPart($part); $orderdetail->setSupplier($lcscSupplier); $orderdetail->setSupplierpartnr('C123456'); @@ -664,7 +666,7 @@ 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->assertEquals(2.0, $bom_entries[0]->getQuantity()); + $this->assertEqualsWithDelta(2.0, $bom_entries[0]->getQuantity(), PHP_FLOAT_EPSILON); $this->assertStringContainsString('LCSC SPN: C123456', $bom_entries[0]->getComment()); $this->assertStringContainsString('Part-DB ID: ' . $part->getID(), $bom_entries[0]->getComment()); @@ -691,7 +693,7 @@ class BOMImporterTest extends WebTestCase $part1->setCategory($this->getDefaultCategory($this->entityManager)); $this->entityManager->persist($part1); - $orderdetail1 = new \App\Entity\PriceInformations\Orderdetail(); + $orderdetail1 = new Orderdetail(); $orderdetail1->setPart($part1); $orderdetail1->setSupplier($lcscSupplier); $orderdetail1->setSupplierpartnr('C123456'); @@ -703,7 +705,7 @@ class BOMImporterTest extends WebTestCase $part2->setCategory($this->getDefaultCategory($this->entityManager)); $this->entityManager->persist($part2); - $orderdetail2 = new \App\Entity\PriceInformations\Orderdetail(); + $orderdetail2 = new Orderdetail(); $orderdetail2->setPart($part2); $orderdetail2->setSupplier($mouserSupplier); $orderdetail2->setSupplierpartnr('789-CAP100NF'); @@ -794,12 +796,12 @@ class BOMImporterTest extends WebTestCase private function getDefaultCategory(EntityManagerInterface $entityManager) { // Get the first available category or create a default one - $categoryRepo = $entityManager->getRepository(\App\Entity\Parts\Category::class); + $categoryRepo = $entityManager->getRepository(Category::class); $categories = $categoryRepo->findAll(); if (empty($categories)) { // Create a default category if none exists - $category = new \App\Entity\Parts\Category(); + $category = new 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 055db8b4..a6c103db 100644 --- a/tests/Services/ImportExportSystem/BOMValidationServiceTest.php +++ b/tests/Services/ImportExportSystem/BOMValidationServiceTest.php @@ -32,18 +32,16 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** * @see \App\Services\ImportExportSystem\BOMValidationService */ -class BOMValidationServiceTest extends WebTestCase +final class BOMValidationServiceTest extends WebTestCase { private BOMValidationService $validationService; - private EntityManagerInterface $entityManager; - private TranslatorInterface $translator; protected function setUp(): void { self::bootKernel(); - $this->entityManager = self::getContainer()->get(EntityManagerInterface::class); - $this->translator = self::getContainer()->get(TranslatorInterface::class); - $this->validationService = new BOMValidationService($this->entityManager, $this->translator); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); + $translator = self::getContainer()->get(TranslatorInterface::class); + $this->validationService = new BOMValidationService($entityManager, $translator); } public function testValidateBOMEntryWithValidData(): void @@ -244,7 +242,7 @@ class BOMValidationServiceTest extends WebTestCase $this->assertTrue($result['is_valid']); $this->assertCount(1, $result['info']); - $this->assertStringContainsString('library prefix', $result['info'][0]); + $this->assertStringContainsString('library prefix', (string) $result['info'][0]); } public function testValidateBOMEntriesWithMultipleEntries(): void @@ -314,7 +312,7 @@ class BOMValidationServiceTest extends WebTestCase $this->assertEquals(2, $stats['error_count']); $this->assertEquals(1, $stats['warning_count']); $this->assertEquals(2, $stats['info_count']); - $this->assertEquals(80.0, $stats['success_rate']); + $this->assertEqualsWithDelta(80.0, $stats['success_rate'], PHP_FLOAT_EPSILON); } public function testGetErrorMessage(): void @@ -344,6 +342,6 @@ class BOMValidationServiceTest extends WebTestCase $message = $this->validationService->getErrorMessage($validation_result); - $this->assertEquals('', $message); + $this->assertSame('', $message); } } \ No newline at end of file diff --git a/tests/Services/ImportExportSystem/EntityExporterTest.php b/tests/Services/ImportExportSystem/EntityExporterTest.php index e9b924b1..8029a2d9 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; -class EntityExporterTest extends WebTestCase +final class EntityExporterTest extends WebTestCase { /** * @var EntityExporter @@ -111,6 +111,6 @@ 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', $response->headers->get('Content-Disposition')); + $this->assertStringContainsString('export_Category_simple.xlsx', (string) $response->headers->get('Content-Disposition')); } } diff --git a/tests/Services/ImportExportSystem/EntityImporterTest.php b/tests/Services/ImportExportSystem/EntityImporterTest.php index 83367f80..b0044dda 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')] -class EntityImporterTest extends WebTestCase +final class EntityImporterTest extends WebTestCase { /** * @var EntityImporter diff --git a/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php index e300e2bf..2fd50f9a 100644 --- a/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/BulkSearchFieldMappingDTOTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\InfoProviderSystem\DTOs; +use App\Services\InfoProviderSystem\Providers\InfoProviderInterface; use App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO; use PHPUnit\Framework\TestCase; -class BulkSearchFieldMappingDTOTest extends TestCase +final class BulkSearchFieldMappingDTOTest extends TestCase { public function testProviderInstanceNormalization(): void { - $mockProvider = $this->createMock(\App\Services\InfoProviderSystem\Providers\InfoProviderInterface::class); + $mockProvider = $this->createMock(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 09fa4973..d3170d9e 100644 --- a/tests/Services/InfoProviderSystem/DTOs/BulkSearchPartResultsDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/BulkSearchPartResultsDTOTest.php @@ -1,4 +1,7 @@ . */ - 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; -class BulkSearchPartResultsDTOTest extends TestCase +final class BulkSearchPartResultsDTOTest extends TestCase { public function testHasErrors(): void { - $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); $this->assertFalse($test->hasErrors()); - $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], ['error1']); + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], ['error1']); $this->assertTrue($test->hasErrors()); } public function testGetErrorCount(): void { - $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); $this->assertCount(0, $test->errors); - $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], ['error1', 'error2']); + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], ['error1', 'error2']); $this->assertCount(2, $test->errors); } public function testHasResults(): void { - $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); $this->assertFalse($test->hasResults()); - $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [ $this->createMock(\App\Services\InfoProviderSystem\DTOs\BulkSearchPartResultDTO::class) ], []); + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [ $this->createStub(BulkSearchPartResultDTO::class) ], []); $this->assertTrue($test->hasResults()); } public function testGetResultCount(): void { - $test = new BulkSearchPartResultsDTO($this->createMock(\App\Entity\Parts\Part::class), [], []); + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [], []); $this->assertCount(0, $test->searchResults); - $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) + $test = new BulkSearchPartResultsDTO($this->createStub(Part::class), [ + $this->createStub(BulkSearchPartResultDTO::class), + $this->createStub(BulkSearchPartResultDTO::class) ], []); $this->assertCount(2, $test->searchResults); } diff --git a/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php index ce7564da..f79d8ce8 100644 --- a/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Services\InfoProviderSystem\DTOs; use App\Entity\Parts\Part; @@ -29,7 +31,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -class BulkSearchResponseDTOTest extends KernelTestCase +final class BulkSearchResponseDTOTest extends KernelTestCase { private EntityManagerInterface $entityManager; diff --git a/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/FileDTOTest.php index 10312aca..fe563fb1 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; -class FileDTOTest extends TestCase +final class FileDTOTest extends TestCase { diff --git a/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php index 4c4e9bfe..6361dc10 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; -class ParameterDTOTest extends TestCase +final 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 1c909e67..480ff924 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; -class PurchaseInfoDTOTest extends TestCase +final 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 dd516c8d..4fbac1f3 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; -class SearchResultDTOTest extends TestCase +final class SearchResultDTOTest extends TestCase { public function testPreviewImageURL(): void { diff --git a/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php b/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php index 45ea9984..8ea6c71a 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; -class DTOtoEntityConverterTest extends WebTestCase +final class DTOtoEntityConverterTest extends WebTestCase { private ?DTOtoEntityConverter $service = null; diff --git a/tests/Services/InfoProviderSystem/ProviderRegistryTest.php b/tests/Services/InfoProviderSystem/ProviderRegistryTest.php index 48a1847f..d3fce441 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; -class ProviderRegistryTest extends TestCase +final class ProviderRegistryTest extends TestCase { /** @var InfoProviderInterface[] */ diff --git a/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php b/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php index 8283b7d3..ef446c9a 100644 --- a/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php +++ b/tests/Services/InfoProviderSystem/Providers/BuerklinProviderTest.php @@ -4,6 +4,7 @@ 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; @@ -18,7 +19,7 @@ use Symfony\Contracts\HttpClient\ResponseInterface; * Full behavioral test suite for BuerklinProvider. * Includes parameter parsing, compliance parsing, images, prices and batch mode. */ -class BuerklinProviderTest extends TestCase +final class BuerklinProviderTest extends TestCase { private HttpClientInterface $httpClient; private CacheItemPoolInterface $cache; @@ -108,14 +109,14 @@ class BuerklinProviderTest extends TestCase $this->assertSame('Zener voltage', $params[0]->name); $this->assertNull($params[0]->value_text); - $this->assertSame(12.0, $params[0]->value_typ); + $this->assertEqualsWithDelta(12.0, $params[0]->value_typ, PHP_FLOAT_EPSILON); $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->assertSame(2.9, $params[1]->value_typ); + $this->assertEqualsWithDelta(2.9, $params[1]->value_typ, PHP_FLOAT_EPSILON); $this->assertSame('mm', $params[1]->unit); $this->assertSame('Assembly', $params[2]->name); @@ -273,75 +274,70 @@ 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(): array + public static function buerklinIdFromUrlProvider(): \Iterator { - 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, - ], + 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, ]; } } diff --git a/tests/Services/InfoProviderSystem/Providers/LCSCProviderTest.php b/tests/Services/InfoProviderSystem/Providers/LCSCProviderTest.php index 57527f57..dc19de6b 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; -class LCSCProviderTest extends TestCase +final class LCSCProviderTest extends TestCase { private LCSCSettings $settings; private LCSCProvider $provider; @@ -67,7 +67,7 @@ class LCSCProviderTest extends TestCase public function testGetProviderKey(): void { - $this->assertEquals('lcsc', $this->provider->getProviderKey()); + $this->assertSame('lcsc', $this->provider->getProviderKey()); } public function testIsActiveWhenEnabled(): void @@ -125,8 +125,8 @@ class LCSCProviderTest extends TestCase $this->assertIsArray($results); $this->assertCount(1, $results); $this->assertInstanceOf(PartDetailDTO::class, $results[0]); - $this->assertEquals('C123456', $results[0]->provider_id); - $this->assertEquals('Test Component', $results[0]->name); + $this->assertSame('C123456', $results[0]->provider_id); + $this->assertSame('Test Component', $results[0]->name); } public function testSearchByKeywordWithRegularTerm(): void @@ -162,8 +162,8 @@ class LCSCProviderTest extends TestCase $this->assertIsArray($results); $this->assertCount(1, $results); $this->assertInstanceOf(PartDetailDTO::class, $results[0]); - $this->assertEquals('C789012', $results[0]->provider_id); - $this->assertEquals('Regular Component', $results[0]->name); + $this->assertSame('C789012', $results[0]->provider_id); + $this->assertSame('Regular Component', $results[0]->name); } public function testSearchByKeywordWithTipProduct(): void @@ -202,8 +202,8 @@ class LCSCProviderTest extends TestCase $this->assertIsArray($results); $this->assertCount(1, $results); $this->assertInstanceOf(PartDetailDTO::class, $results[0]); - $this->assertEquals('C555555', $results[0]->provider_id); - $this->assertEquals('Tip Component', $results[0]->name); + $this->assertSame('C555555', $results[0]->provider_id); + $this->assertSame('Tip Component', $results[0]->name); } public function testSearchByKeywordsBatch(): void @@ -288,12 +288,12 @@ class LCSCProviderTest extends TestCase $result = $this->provider->getDetails('C123456'); $this->assertInstanceOf(PartDetailDTO::class, $result); - $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->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('0603', $result->footprint); - $this->assertEquals('https://www.lcsc.com/product-detail/C123456.html', $result->provider_url); + $this->assertSame('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 @@ class LCSCProviderTest extends TestCase $this->assertIsArray($result); $this->assertCount(1, $result); $this->assertInstanceOf(PurchaseInfoDTO::class, $result[0]); - $this->assertEquals('LCSC', $result[0]->distributor_name); - $this->assertEquals('C123456', $result[0]->order_number); + $this->assertSame('LCSC', $result[0]->distributor_name); + $this->assertSame('C123456', $result[0]->order_number); $this->assertCount(2, $result[0]->prices); } @@ -493,7 +493,7 @@ class LCSCProviderTest extends TestCase $this->httpClient->setResponseFactory([$mockResponse]); $result = $this->provider->getDetails('C123456'); - $this->assertEquals('Electronic Components -> Resistors (SMT)', $result->category); + $this->assertSame('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 fcea7730..248f1ae9 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; -class BarcodeScanHelperTest extends WebTestCase +final 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 3a414997..6d69a773 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; -class EIGP114BarcodeScanResultTest extends TestCase +final 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 69458734..d9185735 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; -class BarcodeContentGeneratorTest extends KernelTestCase +final 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 d681b3b9..e03221e5 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; -class BarcodeHelperTest extends WebTestCase +final class BarcodeHelperTest extends WebTestCase { protected ?BarcodeHelper $service = null; diff --git a/tests/Services/LabelSystem/LabelGeneratorTest.php b/tests/Services/LabelSystem/LabelGeneratorTest.php index 916d4317..5f6d8f04 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; -class LabelGeneratorTest extends WebTestCase +final class LabelGeneratorTest extends WebTestCase { /** * @var LabelGenerator diff --git a/tests/Services/LabelSystem/LabelTextReplacerTest.php b/tests/Services/LabelSystem/LabelTextReplacerTest.php index 346d1bab..c4a140d8 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; -class LabelTextReplacerTest extends WebTestCase +final class LabelTextReplacerTest extends WebTestCase { /** * @var LabelTextReplacer diff --git a/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/AbstractElementProviderTest.php index fb917b82..584f708a 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; -class AbstractElementProviderTest extends WebTestCase +final class AbstractElementProviderTest extends WebTestCase { /** * @var AbstractDBElementProvider diff --git a/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php b/tests/Services/LabelSystem/PlaceholderProviders/GlobalProvidersTest.php index d74bb215..80b6b76f 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; -class GlobalProvidersTest extends WebTestCase +final class GlobalProvidersTest extends WebTestCase { /** * @var GlobalProviders diff --git a/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/NamedElementProviderTest.php index c5efc768..88b77e8e 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; -class NamedElementProviderTest extends WebTestCase +final class NamedElementProviderTest extends WebTestCase { /** * @var NamedElementProvider diff --git a/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/PartLotProviderTest.php index 5aa8f1bd..68425250 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; -class PartLotProviderTest extends WebTestCase +final class PartLotProviderTest extends WebTestCase { /** * @var PartLotProvider diff --git a/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php index 7af936cd..9f1c74f7 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')] -class PartProviderTest extends WebTestCase +final class PartProviderTest extends WebTestCase { /** * @var PartProvider @@ -62,20 +62,15 @@ 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(); - $this->em = self::getContainer()->get(EntityManagerInterface::class); + $em = self::getContainer()->get(EntityManagerInterface::class); - $this->target->setCategory($this->em->find(Category::class, 6)); - $this->target->setFootprint($this->em->find(Footprint::class, 6)); + $this->target->setCategory($em->find(Category::class, 6)); + $this->target->setFootprint($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 6aa152b9..b5415131 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; -class TimestampableElementProviderTest extends WebTestCase +final class TimestampableElementProviderTest extends WebTestCase { /** * @var GlobalProviders diff --git a/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php b/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php index 32317435..f10ef333 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; -class SandboxedTwigFactoryTest extends WebTestCase +final class SandboxedTwigFactoryTest extends WebTestCase { private ?SandboxedTwigFactory $service = null; diff --git a/tests/Services/LogSystem/EventCommentHelperTest.php b/tests/Services/LogSystem/EventCommentHelperTest.php index 9c78d4c6..616c1ddf 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; -class EventCommentHelperTest extends WebTestCase +final class EventCommentHelperTest extends WebTestCase { /** * @var EventCommentHelper diff --git a/tests/Services/LogSystem/EventCommentNeededHelperTest.php b/tests/Services/LogSystem/EventCommentNeededHelperTest.php index 2eb2aceb..3ef238c5 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; -class EventCommentNeededHelperTest extends TestCase +final class EventCommentNeededHelperTest extends TestCase { public function testIsCommentNeeded(): void { diff --git a/tests/Services/LogSystem/EventLoggerTest.php b/tests/Services/LogSystem/EventLoggerTest.php index 0dbb85a3..69870ac8 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; -class EventLoggerTest extends WebTestCase +final class EventLoggerTest extends WebTestCase { /** * @var EventLogger diff --git a/tests/Services/LogSystem/TimeTravelTest.php b/tests/Services/LogSystem/TimeTravelTest.php index f0068778..9b51592d 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; -class TimeTravelTest extends KernelTestCase +final class TimeTravelTest extends KernelTestCase { private TimeTravel $service; diff --git a/tests/Services/Misc/FAIconGeneratorTest.php b/tests/Services/Misc/FAIconGeneratorTest.php index 1aec5d02..445c167c 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; -class FAIconGeneratorTest extends WebTestCase +final class FAIconGeneratorTest extends WebTestCase { /** * @var FAIconGenerator diff --git a/tests/Services/Misc/MySQLDumpXMLConverterTest.php b/tests/Services/Misc/MySQLDumpXMLConverterTest.php index 98614b4b..a56083d8 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; -class MySQLDumpXMLConverterTest extends TestCase +final class MySQLDumpXMLConverterTest extends TestCase { public function testConvertMySQLDumpXMLDataToArrayStructure(): void diff --git a/tests/Services/Misc/RangeParserTest.php b/tests/Services/Misc/RangeParserTest.php index 084ca80b..894034be 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; -class RangeParserTest extends WebTestCase +final class RangeParserTest extends WebTestCase { /** * @var RangeParser diff --git a/tests/Services/Parameters/ParameterExtractorTest.php b/tests/Services/Parameters/ParameterExtractorTest.php index d0b8fed0..353a0697 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; -class ParameterExtractorTest extends WebTestCase +final class ParameterExtractorTest extends WebTestCase { protected $service; diff --git a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php index b033f07e..de684094 100644 --- a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php +++ b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php @@ -18,7 +18,7 @@ class TestPartLot extends PartLot } } -class PartLotWithdrawAddHelperTest extends WebTestCase +final class PartLotWithdrawAddHelperTest extends WebTestCase { /** diff --git a/tests/Services/Parts/PartsTableActionHandlerTest.php b/tests/Services/Parts/PartsTableActionHandlerTest.php index c5105cd7..1772195e 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; -class PartsTableActionHandlerTest extends WebTestCase +final class PartsTableActionHandlerTest extends WebTestCase { private PartsTableActionHandler $service; diff --git a/tests/Services/Parts/PricedetailHelperTest.php b/tests/Services/Parts/PricedetailHelperTest.php index 5d9bd351..08a5d6dd 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; -class PricedetailHelperTest extends WebTestCase +final class PricedetailHelperTest extends WebTestCase { /** * @var AmountFormatter diff --git a/tests/Services/ProjectSystem/ProjectBuildHelperTest.php b/tests/Services/ProjectSystem/ProjectBuildHelperTest.php index 5009f849..fb31b51e 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; -class ProjectBuildHelperTest extends WebTestCase +final class ProjectBuildHelperTest extends WebTestCase { /** @var ProjectBuildHelper */ protected $service; diff --git a/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php b/tests/Services/ProjectSystem/ProjectBuildPartHelperTest.php index 4baa7cf3..894f6315 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; -class ProjectBuildPartHelperTest extends WebTestCase +final class ProjectBuildPartHelperTest extends WebTestCase { /** @var ProjectBuildPartHelper */ protected $service; diff --git a/tests/Services/System/BackupManagerTest.php b/tests/Services/System/BackupManagerTest.php index 145b039d..f75ef8f3 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; -class BackupManagerTest extends KernelTestCase +final class BackupManagerTest extends KernelTestCase { private ?BackupManager $backupManager = null; @@ -77,9 +77,9 @@ class BackupManagerTest extends KernelTestCase $result = preg_match('/pre-update-v([\d.]+)-to-v?([\d.]+)-/', $filename, $matches); - $this->assertEquals(1, $result); - $this->assertEquals('2.5.1', $matches[1]); - $this->assertEquals('2.6.0', $matches[2]); + $this->assertSame(1, $result); + $this->assertSame('2.5.1', $matches[1]); + $this->assertSame('2.6.0', $matches[2]); } /** @@ -90,13 +90,13 @@ 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->assertEquals('1.0.0', $matches1[1]); - $this->assertEquals('2.0.0', $matches1[2]); + $this->assertSame('1.0.0', $matches1[1]); + $this->assertSame('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->assertEquals('1.0.0', $matches2[1]); - $this->assertEquals('2.0.0', $matches2[2]); + $this->assertSame('1.0.0', $matches2[1]); + $this->assertSame('2.0.0', $matches2[2]); } } diff --git a/tests/Services/System/UpdateExecutorTest.php b/tests/Services/System/UpdateExecutorTest.php index 851d060c..48cddf8d 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; -class UpdateExecutorTest extends KernelTestCase +final class UpdateExecutorTest extends KernelTestCase { private ?UpdateExecutor $updateExecutor = null; diff --git a/tests/Services/Trees/NodesListBuilderTest.php b/tests/Services/Trees/NodesListBuilderTest.php index 8f4bf23b..d314114d 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 */ -class NodesListBuilderTest extends WebTestCase +final class NodesListBuilderTest extends WebTestCase { protected $em; /** diff --git a/tests/Services/Trees/TreeViewGeneratorTest.php b/tests/Services/Trees/TreeViewGeneratorTest.php index ebec94d6..190f1068 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')] -class TreeViewGeneratorTest extends WebTestCase +final class TreeViewGeneratorTest extends WebTestCase { protected $em; /** diff --git a/tests/Services/UserSystem/PermissionManagerTest.php b/tests/Services/UserSystem/PermissionManagerTest.php index 478202f4..e6da72d4 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; -class PermissionManagerTest extends WebTestCase +final class PermissionManagerTest extends WebTestCase { protected ?User $user_withoutGroup = null; diff --git a/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php b/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php index 1e41474c..738ff649 100644 --- a/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php +++ b/tests/Services/UserSystem/PermissionSchemaUpdaterTest.php @@ -39,7 +39,7 @@ class TestPermissionHolder implements HasPermissionsInterface } } -class PermissionSchemaUpdaterTest extends WebTestCase +final class PermissionSchemaUpdaterTest extends WebTestCase { /** * @var PermissionSchemaUpdater diff --git a/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php b/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php index 2b6c22d1..5a54f2f3 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; -class BackupCodeGeneratorTest extends TestCase +final 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 35b7f4f8..4b1a0496 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; -class BackupCodeManagerTest extends WebTestCase +final class BackupCodeManagerTest extends WebTestCase { /** * @var BackupCodeManager diff --git a/tests/Services/UserSystem/VoterHelperTest.php b/tests/Services/UserSystem/VoterHelperTest.php index 53d7ee82..3f21c9ab 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; -class VoterHelperTest extends KernelTestCase +final class VoterHelperTest extends KernelTestCase { protected ?VoterHelper $service = null; diff --git a/tests/Settings/SynonymSettingsTest.php b/tests/Settings/SynonymSettingsTest.php index 2d1407ac..00e5be4c 100644 --- a/tests/Settings/SynonymSettingsTest.php +++ b/tests/Settings/SynonymSettingsTest.php @@ -1,4 +1,7 @@ . */ - namespace App\Tests\Settings; use App\Services\ElementTypes; @@ -25,7 +27,7 @@ use App\Settings\SynonymSettings; use App\Tests\SettingsTestHelper; use PHPUnit\Framework\TestCase; -class SynonymSettingsTest extends TestCase +final class SynonymSettingsTest extends TestCase { public function testGetSingularSynonymForType(): void diff --git a/tests/Twig/EntityExtensionTest.php b/tests/Twig/EntityExtensionTest.php index 18fe970b..d206b941 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; -class EntityExtensionTest extends WebTestCase +final class EntityExtensionTest extends WebTestCase { /** @var EntityExtension */ protected $service; @@ -55,20 +55,20 @@ class EntityExtensionTest extends WebTestCase public function testGetEntityType(): void { - $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())); + $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())); } } diff --git a/tests/Twig/TwigCoreExtensionTest.php b/tests/Twig/TwigCoreExtensionTest.php index 1aa1f7ca..be8ced04 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; -class TwigCoreExtensionTest extends WebTestCase +final class TwigCoreExtensionTest extends WebTestCase { /** @var TwigCoreExtension */ protected $service; diff --git a/tests/Twig/UserExtensionTest.php b/tests/Twig/UserExtensionTest.php index 235d39c1..f8422a2c 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; -class UserExtensionTest extends WebTestCase +final class UserExtensionTest extends WebTestCase { protected $service; diff --git a/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php b/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php index 0efcd5de..e4b721ca 100644 --- a/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php +++ b/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php @@ -28,15 +28,12 @@ use App\Validator\Constraints\NoneOfItsChildren; use App\Validator\Constraints\NoneOfItsChildrenValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -class NoneOfItsChildrenValidatorTest extends ConstraintValidatorTestCase +final 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 { @@ -49,14 +46,14 @@ class NoneOfItsChildrenValidatorTest extends ConstraintValidatorTestCase $this->root_node->setName('root')->setParent(null); $this->child1 = new AttachmentType(); $this->child1->setParent($this->root_node)->setName('child1'); - $this->child2 = new AttachmentType(); - $this->child2->setName('child2')->setParent($this->root_node); - $this->child3 = new AttachmentType(); - $this->child3->setName('child3')->setParent($this->root_node); + $child2 = new AttachmentType(); + $child2->setName('child2')->setParent($this->root_node); + $child3 = new AttachmentType(); + $child3->setName('child3')->setParent($this->root_node); $this->child1_1 = new AttachmentType(); $this->child1_1->setName('child1_1')->setParent($this->child1); - $this->child1_2 = new AttachmentType(); - $this->child1_2->setName('child1_2')->setParent($this->child1); + $child1_2 = new AttachmentType(); + $child1_2->setName('child1_2')->setParent($this->child1); } diff --git a/tests/Validator/Constraints/SelectableValidatorTest.php b/tests/Validator/Constraints/SelectableValidatorTest.php index bc520621..68f36f87 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; -class SelectableValidatorTest extends ConstraintValidatorTestCase +final class SelectableValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): SelectableValidator { diff --git a/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php b/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php index d9fab6cf..3863d604 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; -class UniqueObjectCollectionValidatorTest extends ConstraintValidatorTestCase +final class UniqueObjectCollectionValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): UniqueObjectCollectionValidator { diff --git a/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php b/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php index c75754df..326809df 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; -class UrlOrBuiltinValidatorTest extends ConstraintValidatorTestCase +final class UrlOrBuiltinValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): UrlOrBuiltinValidator diff --git a/tests/Validator/Constraints/ValidGTINValidatorTest.php b/tests/Validator/Constraints/ValidGTINValidatorTest.php index f35b053a..6b01519b 100644 --- a/tests/Validator/Constraints/ValidGTINValidatorTest.php +++ b/tests/Validator/Constraints/ValidGTINValidatorTest.php @@ -1,4 +1,7 @@ . */ - 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; -class ValidGTINValidatorTest extends ConstraintValidatorTestCase +final class ValidGTINValidatorTest extends ConstraintValidatorTestCase { public function testAllowNull(): void { - $this->validator->validate(null, new \App\Validator\Constraints\ValidGTIN()); + $this->validator->validate(null, new ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN8(): void { - $this->validator->validate('12345670', new \App\Validator\Constraints\ValidGTIN()); + $this->validator->validate('12345670', new ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN12(): void { - $this->validator->validate('123456789012', new \App\Validator\Constraints\ValidGTIN()); + $this->validator->validate('123456789012', new ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN13(): void { - $this->validator->validate('1234567890128', new \App\Validator\Constraints\ValidGTIN()); + $this->validator->validate('1234567890128', new ValidGTIN()); $this->assertNoViolation(); } public function testValidGTIN14(): void { - $this->validator->validate('12345678901231', new \App\Validator\Constraints\ValidGTIN()); + $this->validator->validate('12345678901231', new ValidGTIN()); $this->assertNoViolation(); } public function testInvalidGTIN(): void { - $this->validator->validate('1234567890123', new \App\Validator\Constraints\ValidGTIN()); + $this->validator->validate('1234567890123', new ValidGTIN()); $this->buildViolation('validator.invalid_gtin') ->assertRaised(); } diff --git a/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php b/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php index 6eb9270e..4924f34b 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; -class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase +final class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): ConstraintValidatorInterface diff --git a/tests/Validator/Constraints/ValidThemeValidatorTest.php b/tests/Validator/Constraints/ValidThemeValidatorTest.php index 9db8f33b..50b11820 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; -class ValidThemeValidatorTest extends ConstraintValidatorTestCase +final class ValidThemeValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): ValidThemeValidator