protected function OrderTotalSummaryTest::setUp in Commerce Core 8.2
Overrides OrderKernelTestBase::setUp
File
- modules/
order/ tests/ src/ Kernel/ OrderTotalSummaryTest.php, line 49
Class
- OrderTotalSummaryTest
- Tests the order total summary.
Namespace
Drupal\Tests\commerce_order\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('commerce_promotion');
$this->orderTotalSummary = $this->container
->get('commerce_order.order_total_summary');
$user = $this
->createUser([
'mail' => $this
->randomString() . '@example.com',
]);
// Turn off title generation to allow explicit values to be used.
$variation_type = ProductVariationType::load('default');
$variation_type
->setGenerateTitle(FALSE);
$variation_type
->save();
$product = Product::create([
'type' => 'default',
'title' => 'Default testing product',
]);
$product
->save();
$variation1 = ProductVariation::create([
'type' => 'default',
'sku' => 'TEST_' . strtolower($this
->randomMachineName()),
'title' => $this
->randomString(),
'status' => 1,
'price' => new Price('12.00', 'USD'),
]);
$variation1
->save();
$product
->addVariation($variation1)
->save();
$profile = Profile::create([
'type' => 'customer',
]);
$profile
->save();
$profile = $this
->reloadEntity($profile);
/** @var \Drupal\commerce_order\Entity\Order $order */
$order = Order::create([
'type' => 'default',
'mail' => $user
->getEmail(),
'uid' => $user
->id(),
'ip_address' => '127.0.0.1',
'order_number' => '6',
'billing_profile' => $profile,
'store_id' => $this->store
->id(),
'state' => 'completed',
]);
$order
->save();
$this->order = $this
->reloadEntity($order);
}