Improved code style of tests

This commit is contained in:
Jan Böhmer 2023-06-11 15:02:59 +02:00
parent 5629215ce4
commit 684334ba22
73 changed files with 196 additions and 38 deletions

View file

@ -5,6 +5,8 @@ declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonyLevelSetList;
@ -42,5 +44,10 @@ return static function (RectorConfig $rectorConfig): void {
//Doctrine rules
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
//PHPUnit rules
PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);
};

View file

@ -36,6 +36,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\AttachmentTypeControllerTest
*/
#[Route(path: '/attachment_type')]
class AttachmentTypeController extends BaseAdminController
{

View file

@ -35,6 +35,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\CategoryControllerTest
*/
#[Route(path: '/category')]
class CategoryController extends BaseAdminController
{

View file

@ -36,6 +36,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\FootprintControllerTest
*/
#[Route(path: '/footprint')]
class FootprintController extends BaseAdminController
{

View file

@ -35,6 +35,9 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\LabelProfileControllerTest
*/
#[Route(path: '/label_profile')]
class LabelProfileController extends BaseAdminController
{

View file

@ -35,6 +35,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\ManufacturerControllerTest
*/
#[Route(path: '/manufacturer')]
class ManufacturerController extends BaseAdminController
{

View file

@ -36,6 +36,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\MeasurementUnitControllerTest
*/
#[Route(path: '/measurement_unit')]
class MeasurementUnitController extends BaseAdminController
{

View file

@ -35,6 +35,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\StorelocationControllerTest
*/
#[Route(path: '/store_location')]
class StorelocationController extends BaseAdminController
{

View file

@ -35,6 +35,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @see \App\Tests\Controller\AdminPages\SupplierControllerTest
*/
#[Route(path: '/supplier')]
class SupplierController extends BaseAdminController
{

View file

@ -97,7 +97,7 @@ class PartListsController extends AbstractController
$attrs['disabled'] = $disabled;
$parent = $form->getParent();
if (!$parent instanceof \Symfony\Component\Form\FormInterface) {
if (!$parent instanceof FormInterface) {
throw new \RuntimeException('This function can only be used on form fields that are children of another form!');
}

View file

@ -30,6 +30,9 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @see \App\Tests\Controller\RedirectControllerTest
*/
class RedirectController extends AbstractController
{
public function __construct(protected string $default_locale, protected TranslatorInterface $translator, protected bool $enforce_index_php)
@ -55,7 +58,7 @@ class RedirectController extends AbstractController
//If either mod_rewrite is not enabled or the index.php version is enforced, add index.php to the string
if (($this->enforce_index_php || !$this->checkIfModRewriteAvailable())
&& !str_contains($new_url, 'index.php')) {
&& !str_contains((string) $new_url, 'index.php')) {
//Like Request::getUriForPath only with index.php
$new_url = $request->getSchemeAndHttpHost().$request->getBaseUrl().'/index.php/'.$locale.$request->getPathInfo();
}

View file

@ -36,6 +36,7 @@ use LogicException;
/**
* Class Attachment.
* @see \App\Tests\Entity\Attachments\AttachmentTest
*/
#[ORM\Entity(repositoryClass: AttachmentRepository::class)]
#[ORM\InheritanceType('SINGLE_TABLE')]

View file

@ -34,6 +34,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class AttachmentType.
* @see \App\Tests\Entity\Attachments\AttachmentTypeTest
*/
#[ORM\Entity(repositoryClass: StructuralDBElementRepository::class)]
#[ORM\Table(name: '`attachment_types`')]

View file

@ -47,6 +47,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
* an attribute of a root element, you will get an exception!
*
*
* @see \App\Tests\Entity\Base\AbstractStructuralDBElementTest
*/
#[UniqueEntity(fields: ['name', 'parent'], ignoreNull: false, message: 'structural.entity.unique_name')]
#[ORM\MappedSuperclass(repositoryClass: StructuralDBElementRepository::class)]

View file

@ -51,6 +51,7 @@ use App\Repository\LogEntryRepository;
/**
* This entity describes an entry in the event log.
* @see \App\Tests\Entity\LogSystem\AbstractLogEntryTest
*/
#[ORM\Entity(repositoryClass: LogEntryRepository::class)]
#[ORM\Table('log')]

View file

@ -47,6 +47,9 @@ use App\Entity\Parts\Part;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @see \App\Tests\Entity\Parameters\PartParameterTest
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
#[ORM\Entity(repositoryClass: ParameterRepository::class)]
class PartParameter extends AbstractParameter

View file

@ -49,6 +49,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
*
* The class properties are split over various traits in directory PartTraits.
* Otherwise, this class would be too big, to be maintained.
* @see \App\Tests\Entity\Parts\PartTest
*/
#[UniqueEntity(fields: ['ipn'], message: 'part.ipn.must_be_unique')]
#[ORM\Entity(repositoryClass: PartRepository::class)]

View file

@ -42,6 +42,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* It is the connection between a part and its store locations.
*
* @ValidPartLot()
* @see \App\Tests\Entity\Parts\PartLotTest
*/
#[ORM\Entity]
#[ORM\HasLifecycleCallbacks]

View file

@ -26,6 +26,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* This class is used to store the permissions of a user.
* This has to be an embeddable or otherwise doctrine could not track the changes of the underlying data array (which is serialized to JSON in the database)
* @see \App\Tests\Entity\UserSystem\PermissionDataTest
*/
#[ORM\Embeddable]
final class PermissionData implements \JsonSerializable

View file

@ -57,6 +57,7 @@ use Jbtronics\TFAWebauthn\Model\TwoFactorInterface as WebauthnTwoFactorInterface
/**
* This entity represents a user, which can log in and have permissions.
* Also, this entity is able to save some information about the user, like the names, email-address and other info.
* @see \App\Tests\Entity\UserSystem\UserTest
*/
#[UniqueEntity('name', message: 'validator.user.username_already_used')]
#[ORM\Entity(repositoryClass: UserRepository::class)]

View file

@ -25,6 +25,9 @@ namespace App\Helpers;
use League\HTMLToMarkdown\HtmlConverter;
use s9e\TextFormatter\Bundles\Forum as TextFormatter;
/**
* @see \App\Tests\Helpers\BBCodeToMarkdownConverterTest
*/
class BBCodeToMarkdownConverter
{
protected HtmlConverter $html_to_markdown;

View file

@ -28,6 +28,7 @@ use App\Validator\Constraints\ProjectSystem\ValidProjectBuildRequest;
/**
* @ValidProjectBuildRequest()
* @see \App\Tests\Helpers\Projects\ProjectBuildRequestTest
*/
final class ProjectBuildRequest
{

View file

@ -26,6 +26,9 @@ use App\Entity\Base\AbstractNamedDBElement;
use App\Entity\UserSystem\User;
use App\Helpers\Trees\TreeViewNode;
/**
* @see \App\Tests\Repository\NamedDBElementRepositoryTest
*/
class NamedDBElementRepository extends DBElementRepository
{
/**

View file

@ -27,6 +27,9 @@ use App\Helpers\Trees\StructuralDBElementIterator;
use App\Helpers\Trees\TreeViewNode;
use RecursiveIteratorIterator;
/**
* @see \App\Tests\Repository\StructuralDBElementRepositoryTest
*/
class StructuralDBElementRepository extends NamedDBElementRepository
{
/**

View file

@ -27,6 +27,9 @@ use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @see \App\Tests\Security\EnsureSAMLUserForSAMLLoginCheckerTest
*/
class EnsureSAMLUserForSAMLLoginChecker implements EventSubscriberInterface
{
public function __construct(private readonly TranslatorInterface $translator)

View file

@ -29,6 +29,9 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @see \App\Tests\Security\SamlUserFactoryTest
*/
class SamlUserFactory implements SamlUserFactoryInterface, EventSubscriberInterface
{
private readonly array $saml_role_mapping;

View file

@ -29,6 +29,9 @@ use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @see \App\Tests\Security\UserCheckerTest
*/
final class UserChecker implements UserCheckerInterface
{
public function __construct(private readonly TranslatorInterface $translator)

View file

@ -24,6 +24,9 @@ use Brick\Math\BigNumber;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* @see \App\Tests\Serializer\BigNumberNormalizerTest
*/
class BigNumberNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
{

View file

@ -32,6 +32,9 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
/**
* @see \App\Tests\Serializer\PartNormalizerTest
*/
class PartNormalizer implements NormalizerInterface, DenormalizerInterface, CacheableSupportsMethodInterface
{
private const DENORMALIZE_KEY_MAPPING = [

View file

@ -27,6 +27,9 @@ use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
/**
* @see \App\Tests\Serializer\StructuralElementDenormalizerTest
*/
class StructuralElementDenormalizer implements DenormalizerInterface, CacheableSupportsMethodInterface
{

View file

@ -26,6 +26,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
/**
* @see \App\Tests\Serializer\StructuralElementFromNameDenormalizerTest
*/
class StructuralElementFromNameDenormalizer implements DenormalizerInterface, CacheableSupportsMethodInterface
{
public function __construct(private readonly EntityManagerInterface $em)

View file

@ -25,6 +25,9 @@ use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
/**
* @see \App\Tests\Serializer\StructuralElementNormalizerTest
*/
class StructuralElementNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
{
public function __construct(private readonly ObjectNormalizer $normalizer)

View file

@ -29,6 +29,7 @@ use Symfony\Component\Filesystem\Filesystem;
/**
* This service converts the relative pathes for attachments saved in database (like %MEDIA%/img.jpg) to real pathes
* an vice versa.
* @see \App\Tests\Services\Attachments\AttachmentPathResolverTest
*/
class AttachmentPathResolver
{

View file

@ -31,6 +31,9 @@ use function strlen;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* @see \App\Tests\Services\Attachments\AttachmentURLGeneratorTest
*/
class AttachmentURLGenerator
{
protected string $public_path;

View file

@ -30,6 +30,7 @@ use Symfony\Contracts\Cache\CacheInterface;
/**
* This service is used to find builtin attachment ressources.
* @see \App\Tests\Services\Attachments\BuiltinAttachmentsFinderTest
*/
class BuiltinAttachmentsFinder
{
@ -57,7 +58,7 @@ class BuiltinAttachmentsFinder
foreach($finder as $file) {
$folder = $file->getRelativePath();
//Normalize path (replace \ with /)
$folder = str_replace('\\', '/', $folder);
$folder = str_replace('\\', '/', (string) $folder);
if(!isset($output[$folder])) {
$output[$folder] = [];

View file

@ -32,6 +32,7 @@ use Symfony\Contracts\Cache\ItemInterface;
* A service that helps to work with filetype filters (based on the format <input type=file> accept uses).
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers for
* more details.
* @see \App\Tests\Services\Attachments\FileTypeFilterToolsTest
*/
class FileTypeFilterTools
{

View file

@ -49,6 +49,9 @@ use Doctrine\ORM\Mapping\Entity;
use function get_class;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @see \App\Tests\Services\ElementTypeNameGeneratorTest
*/
class ElementTypeNameGenerator
{
protected array $mapping;
@ -127,7 +130,7 @@ class ElementTypeNameGenerator
{
$type = $this->getLocalizedTypeLabel($entity);
if ($use_html) {
return '<i>'.$type.':</i> '.htmlspecialchars($entity->getName());
return '<i>'.$type.':</i> '.htmlspecialchars((string) $entity->getName());
}
return $type.': '.$entity->getName();

View file

@ -29,6 +29,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* This service formats a part amount using a Measurement Unit.
* @see \App\Tests\Services\Formatters\AmountFormatterTest
*/
class AmountFormatter
{

View file

@ -24,6 +24,7 @@ namespace App\Services\Formatters;
/**
* A service that helps you to format values using the SI prefixes.
* @see \App\Tests\Services\Formatters\SIFormatterTest
*/
class SIFormatter
{

View file

@ -27,6 +27,9 @@ use League\Csv\Reader;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @see \App\Tests\Services\ImportExportSystem\BOMImporterTest
*/
class BOMImporter
{

View file

@ -36,6 +36,7 @@ use function Symfony\Component\String\u;
/**
* Use this class to export an entity to multiple file formats.
* @see \App\Tests\Services\ImportExportSystem\EntityExporterTest
*/
class EntityExporter
{

View file

@ -36,6 +36,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* @see \App\Tests\Services\ImportExportSystem\EntityImporterTest
*/
class EntityImporter
{
public function __construct(protected SerializerInterface $serializer, protected EntityManagerInterface $em, protected ValidatorInterface $validator)

View file

@ -48,6 +48,9 @@ use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
use Com\Tecnick\Barcode\Barcode;
use InvalidArgumentException;
/**
* @see \App\Tests\Services\LabelSystem\BarcodeGeneratorTest
*/
final class BarcodeGenerator
{
public function __construct(private readonly BarcodeContentGenerator $barcodeContentGenerator)

View file

@ -48,6 +48,9 @@ use App\Entity\Parts\Storelocation;
use InvalidArgumentException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeContentGeneratorTest
*/
final class BarcodeContentGenerator
{
public const PREFIX_MAP = [

View file

@ -43,6 +43,9 @@ namespace App\Services\LabelSystem\Barcodes;
use InvalidArgumentException;
/**
* @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeNormalizerTest
*/
final class BarcodeNormalizer
{
private const PREFIX_TYPE_MAP = [

View file

@ -47,6 +47,9 @@ use Doctrine\ORM\EntityNotFoundException;
use InvalidArgumentException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeRedirectorTest
*/
final class BarcodeRedirector
{
public function __construct(private readonly UrlGeneratorInterface $urlGenerator, private readonly EntityManagerInterface $em)

View file

@ -48,6 +48,9 @@ use App\Entity\Parts\Storelocation;
use Dompdf\Dompdf;
use InvalidArgumentException;
/**
* @see \App\Tests\Services\LabelSystem\LabelGeneratorTest
*/
final class LabelGenerator
{
public const CLASS_SUPPORT_MAPPING = [

View file

@ -46,6 +46,7 @@ use App\Services\LabelSystem\PlaceholderProviders\PlaceholderProviderInterface;
/**
* This service replaces the Placeholders of the user provided lines with the proper informations.
* It uses the PlaceholderProviders provided by PlaceholderProviderInterface classes.
* @see \App\Tests\Services\LabelSystem\LabelTextReplacerTest
*/
final class LabelTextReplacer
{

View file

@ -50,6 +50,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Provides Placeholders for infos about global infos like Installation name or datetimes.
* @see \App\Tests\Services\LabelSystem\PlaceholderProviders\GlobalProvidersTest
*/
final class GlobalProviders implements PlaceholderProviderInterface
{

View file

@ -43,6 +43,9 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
use App\Entity\Contracts\NamedElementInterface;
/**
* @see \App\Tests\Services\LabelSystem\PlaceholderProviders\NamedElementProviderTest
*/
final class NamedElementProvider implements PlaceholderProviderInterface
{
public function replace(string $placeholder, object $label_target, array $options = []): ?string

View file

@ -49,6 +49,9 @@ use App\Services\LabelSystem\LabelTextReplacer;
use IntlDateFormatter;
use Locale;
/**
* @see \App\Tests\Services\LabelSystem\PlaceholderProviders\PartLotProviderTest
*/
final class PartLotProvider implements PlaceholderProviderInterface
{
public function __construct(private readonly LabelTextReplacer $labelTextReplacer, private readonly AmountFormatter $amountFormatter)

View file

@ -49,6 +49,9 @@ use App\Services\Formatters\SIFormatter;
use Parsedown;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @see \App\Tests\Services\LabelSystem\PlaceholderProviders\PartProviderTest
*/
final class PartProvider implements PlaceholderProviderInterface
{
public function __construct(private readonly SIFormatter $siFormatter, private readonly TranslatorInterface $translator)

View file

@ -46,6 +46,9 @@ use DateTime;
use IntlDateFormatter;
use Locale;
/**
* @see \App\Tests\Services\LabelSystem\PlaceholderProviders\TimestampableElementProviderTest
*/
final class TimestampableElementProvider implements PlaceholderProviderInterface
{
public function replace(string $placeholder, object $label_target, array $options = []): ?string

View file

@ -68,6 +68,9 @@ use Twig\Extra\Intl\IntlExtension;
use Twig\Loader\ArrayLoader;
use Twig\Sandbox\SecurityPolicyInterface;
/**
* @see \App\Tests\Services\LabelSystem\SandboxedTwigProviderTest
*/
final class SandboxedTwigProvider
{
private const ALLOWED_TAGS = ['apply', 'autoescape', 'do', 'for', 'if', 'set', 'verbatim', 'with'];

View file

@ -41,6 +41,9 @@ declare(strict_types=1);
namespace App\Services\LogSystem;
/**
* @see \App\Tests\Services\LogSystem\EventCommentHelperTest
*/
class EventCommentHelper
{
protected const MAX_MESSAGE_LENGTH = 255;

View file

@ -23,6 +23,7 @@ namespace App\Services\LogSystem;
/**
* This service is used to check if a log change comment is needed for a given operation type.
* It is configured using the "enforce_change_comments_for" config parameter.
* @see \App\Tests\Services\LogSystem\EventCommentNeededHelperTest
*/
class EventCommentNeededHelper
{

View file

@ -29,6 +29,9 @@ use App\Entity\UserSystem\User;
use App\Services\Misc\ConsoleInfoHelper;
use Doctrine\ORM\EntityManagerInterface;
/**
* @see \App\Tests\Services\LogSystem\EventLoggerTest
*/
class EventLogger
{
public function __construct(protected int $minimum_log_level, protected array $blacklist, protected array $whitelist, protected EntityManagerInterface $em, protected Security $security, protected ConsoleInfoHelper $console_info_helper)

View file

@ -26,6 +26,9 @@ use App\Entity\Attachments\Attachment;
use function in_array;
use InvalidArgumentException;
/**
* @see \App\Tests\Services\Misc\FAIconGeneratorTest
*/
class FAIconGenerator
{
protected const EXT_MAPPING = [

View file

@ -45,6 +45,7 @@ use InvalidArgumentException;
/**
* This Parser allows to parse number ranges like 1-3, 4, 5.
* @see \App\Tests\Services\Misc\RangeParserTest
*/
class RangeParser
{

View file

@ -47,6 +47,9 @@ use InvalidArgumentException;
use function preg_match;
/**
* @see \App\Tests\Services\Parameters\ParameterExtractorTest
*/
class ParameterExtractor
{
protected const ALLOWED_PARAM_SEPARATORS = [', ', "\n"];

View file

@ -8,6 +8,9 @@ use App\Entity\Parts\PartLot;
use App\Services\LogSystem\EventCommentHelper;
use App\Services\LogSystem\EventLogger;
/**
* @see \App\Tests\Services\Parts\PartLotWithdrawAddHelperTest
*/
final class PartLotWithdrawAddHelper
{
public function __construct(private readonly EventLogger $eventLogger, private readonly EventCommentHelper $eventCommentHelper)

View file

@ -32,6 +32,9 @@ use Locale;
use function count;
/**
* @see \App\Tests\Services\Parts\PricedetailHelperTest
*/
class PricedetailHelper
{
protected string $locale;
@ -54,7 +57,7 @@ class PricedetailHelper
foreach ($orderdetails as $orderdetail) {
$pricedetails = $orderdetail->getPricedetails();
//The orderdetail must have pricedetails, otherwise this will not work!
if (0 === count($pricedetails)) {
if (0 === (is_countable($pricedetails) ? count($pricedetails) : 0)) {
continue;
}
@ -99,7 +102,7 @@ class PricedetailHelper
foreach ($orderdetails as $orderdetail) {
$pricedetails = $orderdetail->getPricedetails();
//The orderdetail must have pricedetails, otherwise this will not work!
if (0 === count($pricedetails)) {
if (0 === (is_countable($pricedetails) ? count($pricedetails) : 0)) {
continue;
}

View file

@ -26,6 +26,9 @@ use App\Entity\ProjectSystem\ProjectBOMEntry;
use App\Helpers\Projects\ProjectBuildRequest;
use App\Services\Parts\PartLotWithdrawAddHelper;
/**
* @see \App\Tests\Services\ProjectSystem\ProjectBuildHelperTest
*/
class ProjectBuildHelper
{
public function __construct(private readonly PartLotWithdrawAddHelper $withdraw_add_helper)

View file

@ -5,6 +5,9 @@ namespace App\Services\ProjectSystem;
use App\Entity\Parts\Part;
use App\Entity\ProjectSystem\Project;
/**
* @see \App\Tests\Services\ProjectSystem\ProjectBuildPartHelperTest
*/
class ProjectBuildPartHelper
{
/**

View file

@ -31,6 +31,7 @@ use Symfony\Contracts\Cache\TagAwareCacheInterface;
/**
* This service gives you a flat list containing all structured entities in the order of the structure.
* @see \App\Tests\Services\Trees\NodesListBuilderTest
*/
class NodesListBuilder
{

View file

@ -45,6 +45,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
/**
* @see \App\Tests\Services\Trees\TreeViewGeneratorTest
*/
class TreeViewGenerator
{
public function __construct(protected EntityURLGenerator $urlGenerator, protected EntityManagerInterface $em, protected TagAwareCacheInterface $cache, protected UserCacheKeyGenerator $keyGenerator, protected TranslatorInterface $translator, protected bool $rootNodeExpandedByDefault, protected bool $rootNodeEnabled)
@ -130,43 +133,29 @@ class TreeViewGenerator
protected function entityClassToRootNodeString(string $class): string
{
switch ($class) {
case Category::class:
return $this->translator->trans('category.labelp');
case Storelocation::class:
return $this->translator->trans('storelocation.labelp');
case Footprint::class:
return $this->translator->trans('footprint.labelp');
case Manufacturer::class:
return $this->translator->trans('manufacturer.labelp');
case Supplier::class:
return $this->translator->trans('supplier.labelp');
case Project::class:
return $this->translator->trans('project.labelp');
default:
return $this->translator->trans('tree.root_node.text');
}
return match ($class) {
Category::class => $this->translator->trans('category.labelp'),
Storelocation::class => $this->translator->trans('storelocation.labelp'),
Footprint::class => $this->translator->trans('footprint.labelp'),
Manufacturer::class => $this->translator->trans('manufacturer.labelp'),
Supplier::class => $this->translator->trans('supplier.labelp'),
Project::class => $this->translator->trans('project.labelp'),
default => $this->translator->trans('tree.root_node.text'),
};
}
protected function entityClassToRootNodeIcon(string $class): ?string
{
$icon = "fa-fw fa-treeview fa-solid ";
switch ($class) {
case Category::class:
return $icon . 'fa-tags';
case Storelocation::class:
return $icon . 'fa-cube';
case Footprint::class:
return $icon . 'fa-microchip';
case Manufacturer::class:
return $icon . 'fa-industry';
case Supplier::class:
return $icon . 'fa-truck';
case Project::class:
return $icon . 'fa-archive';
default:
return null;
}
return match ($class) {
Category::class => $icon . 'fa-tags',
Storelocation::class => $icon . 'fa-cube',
Footprint::class => $icon . 'fa-microchip',
Manufacturer::class => $icon . 'fa-industry',
Supplier::class => $icon . 'fa-truck',
Project::class => $icon . 'fa-archive',
default => null,
};
}
/**

View file

@ -37,6 +37,7 @@ use Symfony\Component\Yaml\Yaml;
* This class manages the permissions of users and groups.
* Permissions are defined in the config/permissions.yaml file, and are parsed and resolved by this class using the
* user and hierachical group PermissionData information.
* @see \App\Tests\Services\UserSystem\PermissionManagerTest
*/
class PermissionManager
{

View file

@ -25,6 +25,9 @@ use App\Entity\UserSystem\PermissionData;
use App\Entity\UserSystem\User;
use App\Security\Interfaces\HasPermissionsInterface;
/**
* @see \App\Tests\Services\UserSystem\PermissionSchemaUpdaterTest
*/
class PermissionSchemaUpdater
{
/**

View file

@ -27,6 +27,7 @@ use RuntimeException;
/**
* This class generates random backup codes for two-factor authentication.
* @see \App\Tests\Services\UserSystem\TFA\BackupCodeGeneratorTest
*/
class BackupCodeGenerator
{

View file

@ -26,6 +26,7 @@ use App\Entity\UserSystem\User;
/**
* This services offers methods to manage backup codes for two-factor authentication.
* @see \App\Tests\Services\UserSystem\TFA\BackupCodeManagerTest
*/
class BackupCodeManager
{

View file

@ -42,6 +42,9 @@ use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigTest;
/**
* @see \App\Tests\Twig\EntityExtensionTest
*/
final class EntityExtension extends AbstractExtension
{
public function __construct(protected EntityURLGenerator $entityURLGenerator, protected TreeViewGenerator $treeBuilder, private readonly ElementTypeNameGenerator $nameGenerator)

View file

@ -27,6 +27,7 @@ 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
{

View file

@ -50,6 +50,9 @@ use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
/**
* @see \App\Tests\Twig\UserExtensionTest
*/
final class UserExtension extends AbstractExtension
{
private readonly LogEntryRepository $repo;