protected function OrderWorkflowTest::setUp in Commerce Shipping 8.2
Overrides ShippingKernelTestBase::setUp
File
- tests/
src/ Kernel/ OrderWorkflowTest.php, line 37
Class
- OrderWorkflowTest
- Tests the interaction between order and shipping workflows.
Namespace
Drupal\Tests\commerce_shipping\KernelCode
protected function setUp() : void {
parent::setUp();
$user = $this
->createUser([
'mail' => $this
->randomString() . '@example.com',
]);
$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',
'mail' => $user
->getEmail(),
'uid' => $user
->id(),
'store_id' => $this->store
->id(),
'order_items' => [
$order_item,
],
]);
$order
->save();
$this->order = $this
->reloadEntity($order);
$shipment = Shipment::create([
'type' => 'default',
'order_id' => $this->order
->id(),
'title' => 'Shipment',
'items' => [
new ShipmentItem([
'order_item_id' => 10,
'title' => 'T-shirt (red, large)',
'quantity' => 2,
'weight' => new Weight('40', 'kg'),
'declared_value' => new Price('30', 'USD'),
]),
],
'amount' => new Price('5', 'USD'),
'state' => 'draft',
]);
$shipment
->save();
$this->shipment = $this
->reloadEntity($shipment);
$this->order
->set('shipments', [
$shipment,
]);
$this->order
->save();
}