6 declare(strict_types=1);
38 private $checkoutSession;
43 private $productRepository;
57 $this->checkoutSession = $this->_objectManager->get(Session::class);
58 $this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
59 $this->json = $this->_objectManager->get(Json::class);
60 $this->quote = $this->getQuote(
'test01');
61 $this->checkoutSession->setQuoteId($this->quote->getId());
62 $this->checkoutSession->setCartWasUpdated(
false);
75 public function testExecute($requestQuantity, $expectedResponse)
77 $this->loginCustomer();
81 $product = $this->productRepository->get(
'simple');
82 }
catch (\Exception $e) {
83 $this->fail(
'No such product entity');
87 $this->assertNotFalse(
$quoteItem,
'Cannot get quote item for simple product');
90 if (!empty($requestQuantity) && is_array($requestQuantity)) {
99 $this->
dispatch(
'multishipping/checkout/checkItems');
102 $this->assertEquals($expectedResponse, $this->json->unserialize(
$response));
108 private function loginCustomer()
110 $logger = $this->createMock(\Psr\Log\LoggerInterface::class);
112 $service = $this->_objectManager->create(AccountManagementInterface::class);
115 }
catch (LocalizedException $e) {
116 $this->fail($e->getMessage());
119 $customerSession = $this->_objectManager->create(CustomerSession::class, [
$logger]);
120 $customerSession->setCustomerDataAsLoggedIn(
$customer);
129 private function getQuote($reservedOrderId)
153 'error_message' =>
'We are unable to process your request. Please, try again later.' 157 'request' => [
'qty' => 2],
163 'request' => [
'qty' => 101],
166 'error_message' =>
'The requested qty is not available']
169 'request' => [
'qty' => 230],
172 'error_message' =>
'Maximum qty allowed for Shipping to multiple addresses is 200']
dispatch(RequestInterface $request)