protected function ShippingOrderManagerTest::setUp in Commerce Shipping 8.2
Overrides ShippingKernelTestBase::setUp
File
- tests/
src/ Kernel/ ShippingOrderManagerTest.php, line 56
Class
- ShippingOrderManagerTest
- Tests the shipping order manager.
Namespace
Drupal\Tests\commerce_shipping\KernelCode
protected function setUp() : void {
parent::setUp();
$shipping_method = ShippingMethod::create([
'stores' => $this->store
->id(),
'name' => 'Example',
'plugin' => [
'target_plugin_id' => 'flat_rate',
'target_plugin_configuration' => [
'rate_label' => 'Flat rate',
'rate_amount' => new Price('1', 'USD'),
],
],
'status' => TRUE,
'weight' => 1,
]);
$shipping_method
->save();
$this->shippingMethod = $this
->reloadEntity($shipping_method);
$order_item = OrderItem::create([
'type' => 'test',
'quantity' => 1,
'unit_price' => new Price('12.00', 'USD'),
]);
$order_item
->save();
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = Order::create([
'type' => 'default',
'state' => 'draft',
'store_id' => $this->store
->id(),
'order_items' => [
$order_item,
],
]);
$order
->save();
$this->nonShippableOrder = $this
->reloadEntity($order);
$variation = ProductVariation::create([
'type' => 'default',
'sku' => 'test-product-02',
'title' => 'Mug',
'price' => new Price('10', 'USD'),
]);
$variation
->save();
$another_order_item = OrderItem::create([
'type' => 'default',
'quantity' => 2,
'title' => $variation
->getOrderItemTitle(),
'purchased_entity' => $variation,
'unit_price' => new Price('10', 'USD'),
]);
$another_order_item
->save();
/** @var \Drupal\commerce_order\Entity\OrderInterface $another_order */
$another_order = Order::create([
'type' => 'default',
'state' => 'draft',
'store_id' => $this->store
->id(),
'order_items' => [
$another_order_item,
],
]);
$another_order
->save();
$this->shippableOrder = $this
->reloadEntity($another_order);
$this->shippingOrderManager = $this->container
->get('commerce_shipping.order_manager');
}