Skip to content

Commit

Permalink
Update Magento_Sales integrations tests to fix error when running RMA…
Browse files Browse the repository at this point in the history
… module tests

 - Use the order repository for saving,
 - Use guest customer,
 - Attach email address to order,
  • Loading branch information
dmanners committed Sep 20, 2018
1 parent cb578e7 commit ad35b6f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

use Magento\Sales\Model\Order;
use Magento\Sales\Api\OrderRepositoryInterface;

require 'order.php';
/** @var Order $order */
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
}

0 comments on commit ad35b6f

Please sign in to comment.