Skip to content

Commit

Permalink
pr-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SirDomin committed Apr 28, 2021
1 parent 1df4714 commit 9a07588
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
4 changes: 4 additions & 0 deletions UPGRADE-1.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@
1. API Change Quantity endpoint `PATCH api/v2/admin/orders/{tokenValue}/change-quantity` has been changed to `PATCH api/v2/admin/orders/{tokenValue}/items/{orderItemId}` and its body value `orderItemId` has been removed (now it is a route parameter) and `newQuantity` has been renamed to `quantity`.

1. API Add to cart endpoint `PATCH /api/v2/shop/orders/{tokenValue}/items` no longer requires `productCode` in request body.

### Commands

1. We've removed `productCode` from `Sylius\Bundle\ApiBundle\Command\Cart\AddItemToCart` command.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
public function __invoke(AddItemToCart $addItemToCart): OrderInterface
{
/** @var ProductVariantInterface|null $productVariant */
$productVariant = $this->productVariantRepository->findOneByCode($addItemToCart->productVariantCode);
$productVariant = $this->productVariantRepository->findOneBy(['code' => $addItemToCart->productVariantCode]);

Assert::notNull($productVariant);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function it_adds_simple_product_to_cart(
): void {
$orderRepository->findCartByTokenValue('TOKEN')->willReturn($cart);
$productVariantRepository
->findOneByCode('PRODUCT_VARIANT_CODE')
->findOneBy(['code' => 'PRODUCT_VARIANT_CODE'])
->willReturn($productVariant)
;

Expand All @@ -82,7 +82,7 @@ function it_throws_an_exception_if_product_is_not_found(
ProductVariantRepositoryInterface $productVariantRepository,
CartItemFactoryInterface $cartItemFactory
): void {
$productVariantRepository->findOneByCode('PRODUCT_VARIANT_CODE')->willReturn(null);
$productVariantRepository->findOneBy(['code' => 'PRODUCT_VARIANT_CODE'])->willReturn(null);

$cartItemFactory->createNew()->shouldNotBeCalled();

Expand All @@ -103,7 +103,7 @@ function it_throws_an_exception_if_cart_is_not_found(
ProductVariantInterface $productVariant
): void {
$productVariantRepository
->findOneByCode('PRODUCT_VARIANT_CODE')
->findOneBy(['code' => 'PRODUCT_VARIANT_CODE'])
->willReturn($productVariant)
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,6 @@ public function findOneByCodeAndProductCode(string $code, string $productCode):
;
}

public function findOneByCode(string $code): ?ProductVariantInterface
{
return $this->createQueryBuilder('o')
->innerJoin('o.product', 'product')
->andWhere('o.code = :code')
->setParameter('code', $code)
->getQuery()
->getOneOrNullResult()
;
}

public function findByCodesAndProductCode(array $codes, string $productCode): array
{
return $this->createQueryBuilder('o')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function findByNameAndProduct(string $name, string $locale, ProductInterf

public function findOneByCodeAndProductCode(string $code, string $productCode): ?ProductVariantInterface;

public function findOneByCode(string $code): ?ProductVariantInterface;

/**
* @param array|string[] $codes
*
Expand Down

0 comments on commit 9a07588

Please sign in to comment.