Skip to content

Commit 2ef1774

Browse files
committed
Merge remote-tracking branch 'origin/MC-30658' into 2.3-develop-com-pr24
2 parents a917593 + 7462443 commit 2ef1774

File tree

5 files changed

+133
-11
lines changed

5 files changed

+133
-11
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Checkout\Model\Type\Onepage;
10+
use Magento\Customer\Api\AddressRepositoryInterface;
11+
use Magento\Customer\Api\CustomerRepositoryInterface;
12+
use Magento\Quote\Api\CartRepositoryInterface;
13+
use Magento\Quote\Api\Data\AddressInterface;
14+
use Magento\Quote\Api\Data\AddressInterfaceFactory;
15+
use Magento\Quote\Api\Data\CartInterface;
16+
use Magento\Quote\Api\Data\CartInterfaceFactory;
17+
use Magento\TestFramework\Helper\Bootstrap;
18+
19+
require __DIR__ . '/../../Customer/_files/customer.php';
20+
require __DIR__ . '/../../Customer/_files/customer_address.php';
21+
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated.php';
22+
23+
$objectManager = Bootstrap::getObjectManager();
24+
/** @var ProductRepositoryInterface $productRepository */
25+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
26+
$productRepository->cleanCache();
27+
/** @var CartRepositoryInterface $quoteRepository */
28+
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
29+
/** @var AddressInterface $quoteShippingAddress */
30+
$quoteShippingAddress = $objectManager->get(AddressInterfaceFactory::class)->create();
31+
/** @var CustomerRepositoryInterface $customerRepository */
32+
$customerRepository = $objectManager->get(CustomerRepositoryInterface::class);
33+
/** @var AddressRepositoryInterface $addressRepository */
34+
$addressRepository = $objectManager->get(AddressRepositoryInterface::class);
35+
$quoteShippingAddress->importCustomerAddressData($addressRepository->getById(1));
36+
$customer = $customerRepository->getById(1);
37+
38+
/** @var CartInterface $quote */
39+
$quote = $objectManager->get(CartInterfaceFactory::class)->create();
40+
$quote->setStoreId(1)
41+
->setIsActive(true)
42+
->setIsMultiShipping(0)
43+
->assignCustomerWithAddressChange($customer)
44+
->setShippingAddress($quoteShippingAddress)
45+
->setBillingAddress($quoteShippingAddress)
46+
->setCheckoutMethod(Onepage::METHOD_CUSTOMER)
47+
->setReservedOrderId('55555555')
48+
->setEmail($customer->getEmail());
49+
$quote->addProduct($productRepository->get('simple-1'), 55);
50+
$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate');
51+
$quote->getShippingAddress()->setCollectShippingRates(true);
52+
$quote->getShippingAddress()->collectShippingRates();
53+
$quote->getPayment()->setMethod('checkmo');
54+
$quoteRepository->save($quote);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Quote\Api\CartRepositoryInterface;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
11+
12+
$objectManager = Bootstrap::getObjectManager();
13+
/** @var CartRepositoryInterface $quoteRepository */
14+
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
15+
/** @var GetQuoteByReservedOrderId $getQuoteByReservedOrderId */
16+
$getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class);
17+
$quote = $getQuoteByReservedOrderId->execute('55555555');
18+
if ($quote) {
19+
$quoteRepository->delete($quote);
20+
}
21+
22+
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated_rollback.php';
23+
require __DIR__ . '/../../Customer/_files/customer_address_rollback.php';
24+
require __DIR__ . '/../../Customer/_files/customer_rollback.php';

dev/tests/integration/testsuite/Magento/Sales/Controller/Order/ReorderTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\Sales\Controller\Order;
99

10-
use Magento\Catalog\Api\ProductRepositoryInterface;
1110
use Magento\Checkout\Model\Session as CheckoutSession;
1211
use Magento\Customer\Model\Session;
1312
use Magento\Framework\Message\MessageInterface;
@@ -35,9 +34,6 @@ class ReorderTest extends AbstractController
3534
/** @var Session */
3635
private $customerSession;
3736

38-
/** @var ProductRepositoryInterface */
39-
private $productRepository;
40-
4137
/** @var CartRepositoryInterface */
4238
private $quoteRepository;
4339

@@ -54,8 +50,6 @@ protected function setUp()
5450
$this->checkoutSession = $this->_objectManager->get(CheckoutSession::class);
5551
$this->orderFactory = $this->_objectManager->get(OrderInterfaceFactory::class);
5652
$this->customerSession = $this->_objectManager->get(Session::class);
57-
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
58-
$this->productRepository->cleanCache();
5953
$this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
6054
}
6155

@@ -93,17 +87,14 @@ public function testReorder(): void
9387
}
9488

9589
/**
96-
* @magentoDataFixture Magento/Sales/_files/order_with_two_order_items_with_simple_product.php
90+
* @magentoDataFixture Magento/Sales/_files/customer_order_with_simple_product.php
9791
*
9892
* @return void
9993
*/
10094
public function testReorderProductLowQty(): void
10195
{
102-
$order = $this->orderFactory->create()->loadByIncrementId('100000001');
96+
$order = $this->orderFactory->create()->loadByIncrementId('55555555');
10397
$this->customerSession->setCustomerId($order->getCustomerId());
104-
$product = $this->productRepository->get('simple');
105-
$product->setStockData(['qty' => 3]);
106-
$this->productRepository->save($product);
10798
$this->dispatchReorderRequest((int)$order->getId());
10899
$this->assertSessionMessages(
109100
$this->contains((string)__('The requested qty is not available')),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Quote\Api\CartManagementInterface;
9+
use Magento\Quote\Api\CartRepositoryInterface;
10+
use Magento\TestFramework\Helper\Bootstrap;
11+
12+
require __DIR__ . '/../../Checkout/_files/customer_quote_ready_for_order.php';
13+
14+
$objectManager = Bootstrap::getObjectManager();
15+
/** @var CartRepositoryInterface $quoteRepository */
16+
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
17+
/** @var CartManagementInterface $quoteManagement */
18+
$quoteManagement = $objectManager->get(CartManagementInterface::class);
19+
20+
$quote = $quoteRepository->getActiveForCustomer(1);
21+
$quoteManagement->placeOrder($quote->getId());
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Framework\Registry;
9+
use Magento\Sales\Api\Data\OrderInterfaceFactory;
10+
use Magento\Sales\Api\OrderRepositoryInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
$objectManager = Bootstrap::getObjectManager();
14+
/** @var Registry $registry */
15+
$registry = $objectManager->get(Registry::class);
16+
/** @var OrderRepositoryInterface $orderRepository */
17+
$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
18+
/** @var OrderInterfaceFactory $orderFactory */
19+
$orderFactory = $objectManager->get(OrderInterfaceFactory::class);
20+
21+
$registry->unregister('isSecureArea');
22+
$registry->register('isSecureArea', true);
23+
24+
$order = $orderFactory->create()->loadByIncrementId('55555555');
25+
if ($order->getId()) {
26+
$orderRepository->delete($order);
27+
}
28+
29+
$registry->unregister('isSecureArea');
30+
$registry->register('isSecureArea', false);
31+
32+
require __DIR__ . '/../../Checkout/_files/customer_quote_ready_for_order_rollback.php';

0 commit comments

Comments
 (0)