protected function InvoiceAdminTest::setUp in Commerce Invoice 8.2
Overrides InvoiceBrowserTestBase::setUp
File
- tests/
src/ Functional/ InvoiceAdminTest.php, line 59
Class
- InvoiceAdminTest
- Tests the invoice admin UI.
Namespace
Drupal\Tests\commerce_invoice\FunctionalCode
protected function setUp() : void {
parent::setUp();
$order_type = OrderType::load('default');
$order_type
->setThirdPartySetting('commerce_invoice', 'invoice_type', 'default');
$order_type
->save();
$variation = $this
->createEntity('commerce_product_variation', [
'title' => $this
->randomMachineName(),
'type' => 'default',
'sku' => 'sku-' . $this
->randomMachineName(),
'price' => [
'number' => '7.99',
'currency_code' => 'USD',
],
]);
$order_item = $this
->createEntity('commerce_order_item', [
'title' => $this
->randomMachineName(),
'type' => 'default',
'quantity' => 2,
'unit_price' => new Price('10', 'USD'),
'overridden_unit_price' => TRUE,
'purchased_entity' => $variation,
]);
$order_item
->save();
$adjustment = new Adjustment([
'type' => 'custom',
'label' => 'Random fee',
'amount' => new Price('2.00', 'USD'),
]);
$billing_profile = $this
->createEntity('profile', [
'type' => 'customer',
'uid' => $this->adminUser
->id(),
]);
$this->order = $this
->createEntity('commerce_order', [
'uid' => $this->loggedInUser
->id(),
'order_number' => '6',
'type' => 'default',
'state' => 'draft',
'order_items' => [
$order_item,
],
'adjustments' => [
$adjustment,
],
'store_id' => $this->store,
'billing_profile' => $billing_profile,
]);
$this->collectionUrl = Url::fromRoute('entity.commerce_invoice.collection')
->toString();
$this->orderInvoicesUrl = $this->order
->toUrl('invoices')
->toString();
$this->orderInvoiceAddUrl = $this->order
->toUrl('invoice-add-form')
->toString();
}