You are here

private function OrderCollectionFilterTest::generateTestOrders in Commerce Core 8.2

Generates four test orders.

1. Draft order owned by test customer. 2. Completed order owned by test customer. 3. Completed order owned by other customer. 4. Completed anonymous order.

1 call to OrderCollectionFilterTest::generateTestOrders()
OrderCollectionFilterTest::testCustomerOrderCollectionFiltering in modules/order/tests/src/Kernel/Jsonapi/OrderCollectionFilterTest.php
Tests filtering orders.

File

modules/order/tests/src/Kernel/Jsonapi/OrderCollectionFilterTest.php, line 202

Class

OrderCollectionFilterTest
@group commerce_order

Namespace

Drupal\Tests\commerce_order\Kernel\Jsonapi

Code

private function generateTestOrders() {
  Order::create([
    'uuid' => self::ORDER_CUSTOMER_DRAFT_UUID,
    'type' => 'default',
    'store_id' => $this->store
      ->id(),
    'state' => 'draft',
    'mail' => $this->testOrderCustomer
      ->getEmail(),
    'uid' => $this->testOrderCustomer
      ->id(),
    'ip_address' => '127.0.0.1',
    'order_items' => [
      $this
        ->generateOrderItem(),
    ],
  ])
    ->save();
  Order::create([
    'uuid' => self::ORDER_CUSTOMER_COMPLETED_UUID,
    'type' => 'default',
    'store_id' => $this->store
      ->id(),
    'state' => 'completed',
    'mail' => $this->testOrderCustomer
      ->getEmail(),
    'uid' => $this->testOrderCustomer
      ->id(),
    'ip_address' => '127.0.0.1',
    'order_items' => [
      $this
        ->generateOrderItem(),
    ],
  ])
    ->save();
  Order::create([
    'uuid' => self::OTHER_CUSTOMER_COMPLETED_UUID,
    'type' => 'default',
    'store_id' => $this->store
      ->id(),
    'state' => 'completed',
    'mail' => $this->testOtherCustomer
      ->getEmail(),
    'uid' => $this->testOtherCustomer
      ->id(),
    'ip_address' => '127.0.0.1',
    'order_items' => [
      $this
        ->generateOrderItem(),
    ],
  ])
    ->save();
  Order::create([
    'uuid' => self::ANONYMOUS_COMPLETED_UUID,
    'type' => 'default',
    'store_id' => $this->store
      ->id(),
    'state' => 'completed',
    'mail' => 'foo@bar.com',
    'uid' => 0,
    'ip_address' => '127.0.0.1',
    'order_items' => [
      $this
        ->generateOrderItem(),
    ],
  ])
    ->save();
}