You are here

public function OrderTest::testCreateOrder in Commerce Core 8.2

Tests creating an order programaticaly and through the UI.

File

modules/order/tests/src/Functional/OrderTest.php, line 18

Class

OrderTest
Tests the commerce_order entity forms.

Namespace

Drupal\Tests\commerce_order\Functional

Code

public function testCreateOrder() {
  $order_item = $this
    ->createEntity('commerce_order_item', [
    'type' => 'default',
    'unit_price' => [
      'number' => '999',
      'currency_code' => 'USD',
    ],
  ]);
  $order = $this
    ->createEntity('commerce_order', [
    'type' => 'default',
    'mail' => $this->loggedInUser
      ->getEmail(),
    'order_items' => [
      $order_item,
    ],
    'uid' => $this->loggedInUser,
    'store_id' => $this->store,
  ]);
  $order_exists = (bool) Order::load($order
    ->id());
  $this
    ->assertNotEmpty($order_exists, 'The new order has been created in the database.');
}