Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jun 18, 2024
1 parent 2a7f567 commit 49cfbf2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
7 changes: 7 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@
<function name="var_dump"/>
<function name="print_r"/>
</forbiddenFunctions>
<issueHandlers>
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<file name="src/Form/Type/CustomDiscountCollectionType.php"/>
</errorLevel>
</PropertyNotSetInConstructor>
</issueHandlers>
</psalm>
3 changes: 1 addition & 2 deletions src/Form/Type/CustomDiscountCollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +14,7 @@
abstract class CustomDiscountCollectionType extends AbstractType
{
protected string $label;

protected string $adjustmentType;

public function __construct(
Expand Down
1 change: 0 additions & 1 deletion src/Form/Type/OrderDiscountCollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') %}

<tr>
<td colspan="5" id="promotion-discounts" class="promotion-disabled">
Expand Down
12 changes: 6 additions & 6 deletions tests/Functional/OrderUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -154,10 +154,10 @@ public function testItAllowsToAddDiscountsForTheSpecificOrderItem(): void

$order = $this->getOrderRepository()->findOneBy(['tokenValue' => 'TOKEN']);
self::assertSame($initialOrderTotal - 100, $order->getTotal());

Check failure on line 156 in tests/Functional/OrderUpdateTest.php

View workflow job for this annotation

GitHub Actions / Code Coverage (PHP8.2 | Deps: highest)

Failed asserting that 5878 is identical to 5885.
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),
);
}

Expand All @@ -178,10 +178,10 @@ public function testItAllowsToAddAndRemoveDiscountsForTheOrderItemMultipleTimes(
/** @var EditableOrderInterface $order */
$order = $this->getOrderRepository()->findOneBy(['tokenValue' => 'TOKEN']);
self::assertSame($initialOrderTotal - 200, $order->getTotal());

Check failure on line 180 in tests/Functional/OrderUpdateTest.php

View workflow job for this annotation

GitHub Actions / Code Coverage (PHP8.2 | Deps: highest)

Failed asserting that 5771 is identical to 5785.
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),
);
}

Expand Down

0 comments on commit 49cfbf2

Please sign in to comment.