You are here

protected function UsageTest::setUp in Commerce Core 8.2

Overrides OrderKernelTestBase::setUp

File

modules/promotion/tests/src/Kernel/UsageTest.php, line 64

Class

UsageTest
Tests the usage tracking of promotions.

Namespace

Drupal\Tests\commerce_promotion\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('commerce_promotion');
  $this
    ->installEntitySchema('commerce_promotion_coupon');
  $this
    ->installConfig([
    'commerce_promotion',
  ]);
  $this
    ->installSchema('commerce_promotion', [
    'commerce_promotion_usage',
  ]);
  $this->couponStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('commerce_promotion_coupon');
  $this->promotionStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('commerce_promotion');
  $this->usage = $this->container
    ->get('commerce_promotion.usage');
  $order_item = OrderItem::create([
    'type' => 'test',
    'quantity' => 1,
    'unit_price' => new Price('12.00', 'USD'),
  ]);
  $order_item
    ->save();
  $this->order = Order::create([
    'type' => 'default',
    'state' => 'draft',
    'mail' => 'test@example.com',
    'ip_address' => '127.0.0.1',
    'order_number' => '6',
    'store_id' => $this->store,
    'uid' => $this
      ->createUser(),
    'order_items' => [
      $order_item,
    ],
  ]);
}