6 declare(strict_types=1);
39 private $searchCriteriaBuilder;
44 private $cartRepository;
49 private $stockRepository;
54 private $storeRepository;
59 private $storeManager;
64 private $productRepository;
69 private $cartManagement;
74 private $dataObjectFactory;
79 private $cleanupReservations;
89 private $orderRepository;
94 private $orderManagement;
99 private $getSalableQuantity;
138 $product = $this->productRepository->get(
'configurable');
139 $quote = $this->getCartByStockId($stockId);
141 $this->cartRepository->save(
$quote);
142 $salableQtyBeforeOrder = $this->getSalableQuantity->execute(
'simple_10', $stockId);
143 $orderId = $this->cartManagement->placeOrder(
$quote->getId());
146 $this->deleteOrderById((
int)$orderId);
147 $salableQtyAfterOrderCancel = $this->getSalableQuantity->execute(
'simple_10', $stockId);
150 $this->assertEquals($salableQtyBeforeOrder, $salableQtyAfterOrderCancel);
163 return $this->dataObjectFactory->create(
165 'product' =>
$option[
'product_id'],
176 private function getCartByStockId(
int $stockId): CartInterface
179 ->addFilter(
'reserved_order_id',
'test_order_1')
184 $stock = $this->stockRepository->get($stockId);
196 $this->storeManager->setCurrentStore(
$storeCode);
205 private function deleteOrderById(
int $orderId)
207 $this->registry->unregister(
'isSecureArea');
208 $this->registry->register(
'isSecureArea',
true);
209 $this->orderManagement->cancel($orderId);
210 $this->orderRepository->delete($this->orderRepository->get($orderId));
211 $this->registry->unregister(
'isSecureArea');
212 $this->registry->register(
'isSecureArea',
false);
217 $this->cleanupReservations->execute();
testPlaceReservationWhenOrderItemIsCanceled()
static getObjectManager()