-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Magento_Sales integrations tests to fix error when running RMA…
… module tests - Use the order repository for saving, - Use guest customer, - Attach email address to order,
- Loading branch information
Showing
1 changed file
with
9 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*/ | ||
|
||
use Magento\Sales\Model\Order; | ||
use Magento\Sales\Api\OrderRepositoryInterface; | ||
|
||
require 'order.php'; | ||
/** @var Order $order */ | ||
|
@@ -47,6 +48,8 @@ | |
], | ||
]; | ||
|
||
/** @var OrderRepositoryInterface $orderRepository */ | ||
$orderRepository = $objectManager->create(OrderRepositoryInterface::class); | ||
/** @var array $orderData */ | ||
foreach ($orders as $orderData) { | ||
/** @var $order \Magento\Sales\Model\Order */ | ||
|
@@ -60,13 +63,16 @@ | |
$billingAddress->setAddressType('billing'); | ||
|
||
/** @var Order\Address $shippingAddress */ | ||
$shippingAddress = clone $billingAddress; | ||
$shippingAddress->setId(null)->setAddressType('shipping'); | ||
$shippingAddress = $objectManager->create(\Magento\Sales\Model\Order\Address::class, ['data' => $addressData]); | ||
$shippingAddress->setAddressType('shipping'); | ||
|
||
$order | ||
->setData($orderData) | ||
->addItem($orderItem) | ||
->setBillingAddress($billingAddress) | ||
->setShippingAddress($shippingAddress) | ||
->save(); | ||
->setCustomerIsGuest(true) | ||
->setCustomerEmail('[email protected]'); | ||
|
||
$orderRepository->save($order); | ||
} |