protected function OrderIntegrationTest::setUp in Commerce Invoice 8.2
Overrides InvoiceKernelTestBase::setUp
1 call to OrderIntegrationTest::setUp()
- InvoiceOrderAccessCheckTest::setUp in tests/
src/ Kernel/ InvoiceOrderAccessCheckTest.php
1 method overrides OrderIntegrationTest::setUp()
- InvoiceOrderAccessCheckTest::setUp in tests/
src/ Kernel/ InvoiceOrderAccessCheckTest.php
File
- tests/
src/ Kernel/ OrderIntegrationTest.php, line 42
Class
- OrderIntegrationTest
- Tests integration with order events.
Namespace
Drupal\Tests\commerce_invoice\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'commerce_product',
]);
$this
->installEntitySchema('commerce_product');
$this
->installEntitySchema('commerce_product_variation');
$user = $this
->createUser([
'mail' => $this
->randomString() . '@example.com',
]);
$this->invoiceStorage = $this->container
->get('entity_type.manager')
->getStorage('commerce_invoice');
// 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\OrderItemStorageInterface $order_item_storage */
$order_item_storage = $this->container
->get('entity_type.manager')
->getStorage('commerce_order_item');
$order_item1 = $order_item_storage
->createFromPurchasableEntity($variation1);
$order_item1
->save();
$order = Order::create([
'type' => 'default',
'store_id' => $this->store
->id(),
'state' => 'draft',
'mail' => $user
->getEmail(),
'uid' => $user
->id(),
'ip_address' => '127.0.0.1',
'order_number' => '6',
'billing_profile' => $profile,
'order_items' => [
$order_item1,
],
]);
$order
->save();
$this->order = $this
->reloadEntity($order);
}