protected function MonitoringCommerceTest::createEmptyOrderWithPrice in Monitoring 8
Create an order for testing purposes.
Parameters
string $state: State in which the order should be created.
mixed $amount: The total price of the order.
string $currency: Currency of the total price.
1 call to MonitoringCommerceTest::createEmptyOrderWithPrice()
- MonitoringCommerceTest::testTurnoverSensor in tests/
src/ Functional/ MonitoringCommerceTest.php - Tests the commerce turnover sensor.
File
- tests/
src/ Functional/ MonitoringCommerceTest.php, line 150
Class
- MonitoringCommerceTest
- Tests the commerce turnover sensor.
Namespace
Drupal\Tests\monitoring\FunctionalCode
protected function createEmptyOrderWithPrice($state, $amount = 100, $currency = 'CHF') {
$order_item = OrderItem::create([
'type' => 'test',
'quantity' => 1,
'unit_price' => new Price((string) $amount, $currency),
'overridden_unit_price' => TRUE,
]);
$order_item
->save();
$order = Order::create([
'type' => 'default',
'state' => $state,
'store_id' => \Drupal::service('commerce_store.current_store')
->getStore()
->id(),
'order_items' => [
$order_item,
],
]);
$order
->save();
}