protected function LateOrderProcessorTest::setUp in Commerce Shipping 8.2
Overrides ShippingKernelTestBase::setUp
File
- tests/
src/ Kernel/ LateOrderProcessorTest.php, line 38
Class
- LateOrderProcessorTest
- Tests the late order processor.
Namespace
Drupal\Tests\commerce_shipping\KernelCode
protected function setUp() : void {
parent::setUp();
$this->processor = $this->container
->get('commerce_shipping.late_order_processor');
$variation = ProductVariation::create([
'type' => 'default',
'sku' => 'test-product-01',
'title' => 'Hat',
'price' => new Price('10', 'USD'),
'weight' => new Weight('0', 'g'),
]);
$variation
->save();
$first_order_item = OrderItem::create([
'type' => 'default',
'quantity' => 2,
'title' => $variation
->getOrderItemTitle(),
'purchased_entity' => $variation,
'unit_price' => new Price('10', 'USD'),
]);
$first_order_item
->save();
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = Order::create([
'type' => 'default',
'uid' => $this
->createUser([
'mail' => $this
->randomString() . '@example.com',
]),
'store_id' => $this->store
->id(),
'order_items' => [
$first_order_item,
],
]);
$order
->save();
/** @var \Drupal\profile\Entity\ProfileInterface $shipping_profile */
$shipping_profile = Profile::create([
'type' => 'customer',
'address' => [
'country_code' => 'FR',
],
]);
$shipping_profile
->save();
// Create the first shipment.
$shipping_order_manager = $this->container
->get('commerce_shipping.order_manager');
$shipments = $shipping_order_manager
->pack($order, $shipping_profile);
$order
->set('shipments', $shipments);
$order
->setRefreshState(Order::REFRESH_SKIP);
$order
->save();
$this->order = $order;
}