From 35054d96a3356e7215c924fa835f0e6b47003a42 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Fri, 30 Aug 2024 12:04:46 +0200 Subject: [PATCH] Fix tests --- dist/src/Entity/Channel/Channel.php | 11 ++-- phpstan.neon | 1 - phpunit.xml.dist | 55 +++++++++++++++++++ .../FirewallRegistryPass.php | 6 +- src/Form/Type/Settings/NoCommerceType.php | 3 + .../TemplateBlockRegistryDecorator.php | 1 - src/Routing/NoCommerceRequestContext.php | 2 +- tests/Unit/.gitkeep | 0 8 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 phpunit.xml.dist create mode 100644 tests/Unit/.gitkeep diff --git a/dist/src/Entity/Channel/Channel.php b/dist/src/Entity/Channel/Channel.php index 2ff69ee..8a5810c 100644 --- a/dist/src/Entity/Channel/Channel.php +++ b/dist/src/Entity/Channel/Channel.php @@ -18,11 +18,12 @@ #[ORM\Entity()] #[ORM\Table(name: 'sylius_channel')] -#[ORM\AssociationOverrides([ - new ORM\AssociationOverride( - name: 'baseCurrency', - joinColumns: new ORM\JoinColumn(name: 'base_currency_id', referencedColumnName: 'id', nullable: true) - )] +#[ORM\AssociationOverrides( + [ + new ORM\AssociationOverride( + name: 'baseCurrency', + joinColumns: new ORM\JoinColumn(name: 'base_currency_id', referencedColumnName: 'id', nullable: true) + )] )] /** * @ORM\Entity diff --git a/phpstan.neon b/phpstan.neon index 889ab8d..4ca0c04 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,5 +12,4 @@ parameters: - 'tests/Application/**/*' ignoreErrors: - - identifier: missingType.generics - identifier: missingType.iterableValue diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..da7719d --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,55 @@ + + + + + + tests/Unit + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/DependencyInjection/FirewallRegistryPass.php b/src/DependencyInjection/FirewallRegistryPass.php index f2148e2..af90f1b 100644 --- a/src/DependencyInjection/FirewallRegistryPass.php +++ b/src/DependencyInjection/FirewallRegistryPass.php @@ -17,11 +17,14 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; +use Symfony\Component\DependencyInjection\Reference; final class FirewallRegistryPass implements CompilerPassInterface { + /** + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ public function process(ContainerBuilder $container): void { $registry = $container->findDefinition('MonsieurBiz\SyliusNoCommercePlugin\Firewall\RegistryInterface'); @@ -30,6 +33,7 @@ public function process(ContainerBuilder $container): void if (!$configuration instanceof ChildDefinition) { continue; } + try { $parent = $container->getDefinition($configuration->getParent()); } catch (ServiceNotFoundException $e) { diff --git a/src/Form/Type/Settings/NoCommerceType.php b/src/Form/Type/Settings/NoCommerceType.php index 42106e0..5f717c6 100644 --- a/src/Form/Type/Settings/NoCommerceType.php +++ b/src/Form/Type/Settings/NoCommerceType.php @@ -40,6 +40,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $choices = []; foreach ($this->firewallRegistry as $firewall) { $firewallConfig = $firewall->getConfig(); + if (null === $firewallConfig) { + continue; + } $firewallName = $firewallConfig->getName(); if (\in_array($firewallName, self::FIREWALLS_NAMES_CANNOT_BE_DISABLED, true)) { continue; diff --git a/src/Registry/TemplateBlockRegistryDecorator.php b/src/Registry/TemplateBlockRegistryDecorator.php index e061e9e..3a78051 100644 --- a/src/Registry/TemplateBlockRegistryDecorator.php +++ b/src/Registry/TemplateBlockRegistryDecorator.php @@ -92,7 +92,6 @@ public function findEnabledForEvents(array $eventNames): array $templateBlocksPriorityQueue->insert($templateBlock, $templateBlock->getPriority()); } - /** @phpstan-ignore-next-line */ return $templateBlocksPriorityQueue->toArray(); } diff --git a/src/Routing/NoCommerceRequestContext.php b/src/Routing/NoCommerceRequestContext.php index 288916b..90710c9 100644 --- a/src/Routing/NoCommerceRequestContext.php +++ b/src/Routing/NoCommerceRequestContext.php @@ -58,6 +58,6 @@ public function __call(string $name, array $arguments) return \call_user_func($callback, ...$arguments); } - throw new Exception(sprintf('Method %s not found for class "%s"', $name, \get_class($this->decorated))); + throw new Exception(\sprintf('Method %s not found for class "%s"', $name, \get_class($this->decorated))); } } diff --git a/tests/Unit/.gitkeep b/tests/Unit/.gitkeep new file mode 100644 index 0000000..e69de29