Skip to content

Commit

Permalink
[API][Orders] Validate item quantity change
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafikooo committed Jul 3, 2023
1 parent 0ab079e commit 200ea9e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
11 changes: 1 addition & 10 deletions UPGRADE-API-1.13.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# UPGRADE FROM `v1.12.x` TO `v1.13.0`

1. The signature of constructor and `createFromData` method of 'Sylius\Bundle\ApiBundle\Command\Cart\ChangeItemQuantityCart' command changed:
1. The signature of constructor of 'Sylius\Bundle\ApiBundle\Command\Cart\ChangeItemQuantityInCart' command changed:

````diff
public function __construct(
Expand All @@ -10,15 +10,6 @@
}
````

````diff
public static function createFromData(
string $tokenValue,
string $orderItemId,
- int $quantity,
+ ?int $quantity,
): self
````

1. The constructor signature of 'Sylius\Bundle\ApiBundle\Command\Cart\AddItemToCart' changed:

````diff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<option name="minMessage">sylius.order_item.quantity.min</option>
<option name="groups">sylius</option>
</constraint>
<constraint name="NotBlank">
<option name="message">sylius.order_item.quantity.not_blank</option>
<option name="groups">sylius</option>
</constraint>
</property>
</class>
</constraint-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function validate($value, Constraint $constraint)
/** @var ChangedItemQuantityInCart $constraint */
Assert::isInstanceOf($constraint, ChangedItemQuantityInCart::class);

if ($value->quantity === null) {
return;
}

/** @var OrderItemInterface|null $orderItem */
$orderItem = $this->orderItemRepository->findOneBy(['id' => $value->orderItemId]);
Assert::notNull($orderItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace spec\Sylius\Bundle\ApiBundle\Validator\Constraints;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Bundle\ApiBundle\Command\Cart\ChangeItemQuantityInCart;
use Sylius\Bundle\ApiBundle\Command\Checkout\CompleteOrder;
use Sylius\Bundle\ApiBundle\Validator\Constraints\AddingEligibleProductVariantToCart;
Expand Down

0 comments on commit 200ea9e

Please sign in to comment.