protected function OrderTestTrait::createOrder in Ubercart 8.4
Creates a new order directly, without going through checkout.
Parameters
array $edit: (optional) An associative array of order fields to change from the defaults, keys are order field names. For example, 'price' => '12.34'.
Return value
\Drupal\uc_order\OrderInterface The created Order entity.
10 calls to OrderTestTrait::createOrder()
- CartCheckoutTest::testCheckoutComplete in uc_cart/
tests/ src/ Functional/ CartCheckoutTest.php - Tests checkout complete functioning.
- CreditCardTest::testExpiryDate in payment/
uc_credit/ tests/ src/ Functional/ CreditCardTest.php - Tests that expiry date validation functions correctly.
- FileCheckoutTest::testCheckoutFileDownload in uc_file/
tests/ src/ Functional/ FileCheckoutTest.php - Tests that purchased files may be downloaded after checkout.
- FulfillmentRulesEventsTest::testRulesEvents in shipping/
uc_fulfillment/ tests/ src/ Functional/ FulfillmentRulesEventsTest.php - Tests the one event provided by uc_fulfillment.
- FulfillmentTest::testFulfillmentProcess in shipping/
uc_fulfillment/ tests/ src/ Functional/ FulfillmentTest.php - Tests packaging and shipping a simple order with the "Manual" plugin.
File
- uc_order/
tests/ src/ Traits/ OrderTestTrait.php, line 29
Class
- OrderTestTrait
- Utility functions to provide orders for test purposes.
Namespace
Drupal\Tests\uc_order\TraitsCode
protected function createOrder(array $edit = []) {
if (empty($edit['primary_email'])) {
$edit['primary_email'] = $this
->randomMachineName(8) . '@example.org';
}
$order = Order::create($edit);
if (!isset($edit['products'])) {
$product = $this
->createProduct();
$order->products[] = OrderProduct::create([
'nid' => $product->nid->target_id,
'title' => $product->title->value,
'model' => $product->model,
'qty' => 1,
'cost' => $product->cost->value,
'price' => $product->price->value,
'weight' => $product->weight,
'data' => [],
]);
}
$order
->save();
return Order::load($order
->id());
}