From 49cfbf2cb7ec25acbb98b64f50d691c40a44727a Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Tue, 18 Jun 2024 13:09:39 +0200 Subject: [PATCH] CS fixes --- psalm.xml | 7 +++++++ src/Form/Type/CustomDiscountCollectionType.php | 3 +-- src/Form/Type/OrderDiscountCollectionType.php | 1 - .../Order/Show/Summary/_item.html.twig | 2 +- .../Order/Show/Summary/_totalsPromotions.html.twig | 2 +- tests/Functional/OrderUpdateTest.php | 12 ++++++------ 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/psalm.xml b/psalm.xml index ab9fc1c..d8cfc97 100644 --- a/psalm.xml +++ b/psalm.xml @@ -29,4 +29,11 @@ + + + + + + + diff --git a/src/Form/Type/CustomDiscountCollectionType.php b/src/Form/Type/CustomDiscountCollectionType.php index 01139f3..816873f 100644 --- a/src/Form/Type/CustomDiscountCollectionType.php +++ b/src/Form/Type/CustomDiscountCollectionType.php @@ -4,8 +4,6 @@ namespace Setono\SyliusOrderEditPlugin\Form\Type; -use Setono\SyliusOrderEditPlugin\Model\OrderEditDiscountTypes; -use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Order\Factory\AdjustmentFactoryInterface; use Sylius\Component\Order\Model\AdjustableInterface; use Sylius\Component\Order\Model\AdjustmentInterface; @@ -16,6 +14,7 @@ abstract class CustomDiscountCollectionType extends AbstractType { protected string $label; + protected string $adjustmentType; public function __construct( diff --git a/src/Form/Type/OrderDiscountCollectionType.php b/src/Form/Type/OrderDiscountCollectionType.php index ba0b61e..4afb131 100644 --- a/src/Form/Type/OrderDiscountCollectionType.php +++ b/src/Form/Type/OrderDiscountCollectionType.php @@ -5,7 +5,6 @@ namespace Setono\SyliusOrderEditPlugin\Form\Type; use Setono\SyliusOrderEditPlugin\Model\AdjustmentTypes; -use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Order\Factory\AdjustmentFactoryInterface; final class OrderDiscountCollectionType extends CustomDiscountCollectionType diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig index a7f0d9b..89b0cb7 100644 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig @@ -2,7 +2,7 @@ {% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} {% set unitPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT') %} -{% set adminOrderItemDiscountAdjustment = constant('Setono\\SyliusOrderEditPlugin\\Model\\OrderEditDiscountTypes::SETONO_ADMIN_ORDER_ITEM_DISCOUNT') %} +{% set adminOrderItemDiscountAdjustment = constant('Setono\\SyliusOrderEditPlugin\\Model\\AdjustmentTypes::SETONO_ADMIN_ORDER_ITEM_DISCOUNT') %} {% set shippingAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::SHIPPING_ADJUSTMENT') %} {% set taxAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::TAX_ADJUSTMENT') %} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totalsPromotions.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totalsPromotions.html.twig index 877b4c9..46db361 100644 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totalsPromotions.html.twig +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totalsPromotions.html.twig @@ -2,7 +2,7 @@ {% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} {% set unitPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT') %} -{% set adminOrderDiscountAdjustment = constant('Setono\\SyliusOrderEditPlugin\\Model\\OrderEditDiscountTypes::SETONO_ADMIN_ORDER_DISCOUNT') %} +{% set adminOrderDiscountAdjustment = constant('Setono\\SyliusOrderEditPlugin\\Model\\AdjustmentTypes::SETONO_ADMIN_ORDER_DISCOUNT') %} diff --git a/tests/Functional/OrderUpdateTest.php b/tests/Functional/OrderUpdateTest.php index 8e534b6..4f57391 100644 --- a/tests/Functional/OrderUpdateTest.php +++ b/tests/Functional/OrderUpdateTest.php @@ -7,7 +7,7 @@ use Doctrine\ORM\EntityManagerInterface; use Setono\SyliusOrderEditPlugin\Entity\EditableOrderInterface; use Setono\SyliusOrderEditPlugin\Entity\InitialTotalAwareOrderInterface; -use Setono\SyliusOrderEditPlugin\Model\OrderEditDiscountTypes; +use Setono\SyliusOrderEditPlugin\Model\AdjustmentTypes; use Sylius\Bundle\ApiBundle\Command\Cart\AddItemToCart; use Sylius\Bundle\ApiBundle\Command\Cart\PickupCart; use Sylius\Bundle\ApiBundle\Command\Checkout\ChoosePaymentMethod; @@ -116,7 +116,7 @@ public function testItAllowsToAddAndRemoveDiscountsForTheWholeOrderMultipleTimes /** @var EditableOrderInterface $order */ $order = $this->getOrderRepository()->findOneBy(['tokenValue' => 'TOKEN']); self::assertSame($initialOrderTotal - 200, $order->getTotal()); - self::assertSame(-200, $order->getAdjustmentsTotal(OrderEditDiscountTypes::SETONO_ADMIN_ORDER_DISCOUNT)); + self::assertSame(-200, $order->getAdjustmentsTotal(AdjustmentTypes::SETONO_ADMIN_ORDER_DISCOUNT)); } public function testItDoesNotAllowToExceedTheInitialOrderTotal(): void @@ -154,10 +154,10 @@ public function testItAllowsToAddDiscountsForTheSpecificOrderItem(): void $order = $this->getOrderRepository()->findOneBy(['tokenValue' => 'TOKEN']); self::assertSame($initialOrderTotal - 100, $order->getTotal()); - self::assertSame(0, $order->getAdjustmentsTotal(OrderEditDiscountTypes::SETONO_ADMIN_ORDER_DISCOUNT)); + self::assertSame(0, $order->getAdjustmentsTotal(AdjustmentTypes::SETONO_ADMIN_ORDER_DISCOUNT)); self::assertSame( -100, - $order->getItems()->first()->getAdjustmentsTotal(OrderEditDiscountTypes::SETONO_ADMIN_ORDER_ITEM_DISCOUNT), + $order->getItems()->first()->getAdjustmentsTotal(AdjustmentTypes::SETONO_ADMIN_ORDER_ITEM_DISCOUNT), ); } @@ -178,10 +178,10 @@ public function testItAllowsToAddAndRemoveDiscountsForTheOrderItemMultipleTimes( /** @var EditableOrderInterface $order */ $order = $this->getOrderRepository()->findOneBy(['tokenValue' => 'TOKEN']); self::assertSame($initialOrderTotal - 200, $order->getTotal()); - self::assertSame(0, $order->getAdjustmentsTotal(OrderEditDiscountTypes::SETONO_ADMIN_ORDER_DISCOUNT)); + self::assertSame(0, $order->getAdjustmentsTotal(AdjustmentTypes::SETONO_ADMIN_ORDER_DISCOUNT)); self::assertSame( -200, - $order->getItems()->first()->getAdjustmentsTotal(OrderEditDiscountTypes::SETONO_ADMIN_ORDER_ITEM_DISCOUNT), + $order->getItems()->first()->getAdjustmentsTotal(AdjustmentTypes::SETONO_ADMIN_ORDER_ITEM_DISCOUNT), ); }