You are here

protected function OrderItemPercentageOffTest::setUp in Commerce Core 8.2

Overrides OrderKernelTestBase::setUp

File

modules/promotion/tests/src/Kernel/Plugin/Commerce/PromotionOffer/OrderItemPercentageOffTest.php, line 48

Class

OrderItemPercentageOffTest
Tests the percentage off offer for order items.

Namespace

Drupal\Tests\commerce_promotion\Kernel\Plugin\Commerce\PromotionOffer

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('commerce_promotion');
  $this
    ->installConfig([
    'commerce_promotion',
  ]);
  $this
    ->installSchema('commerce_promotion', [
    'commerce_promotion_usage',
  ]);
  $variation = ProductVariation::create([
    'type' => 'default',
    'sku' => strtolower($this
      ->randomMachineName()),
    'price' => [
      'number' => '9.99',
      'currency_code' => 'USD',
    ],
  ]);
  $variation
    ->save();
  $this->variation = $variation;
  $product = Product::create([
    'type' => 'default',
    'title' => 'My product',
    'variations' => [
      $variation,
    ],
  ]);
  $product
    ->save();
  $this->order = Order::create([
    'type' => 'default',
    'state' => 'completed',
    'mail' => 'test@example.com',
    'ip_address' => '127.0.0.1',
    'order_number' => '6',
    'uid' => $this
      ->createUser(),
    'store_id' => $this->store,
    'order_items' => [],
  ]);
}