You are here

protected function CombinationOfferTest::setUp in Commerce Core 8.2

Overrides OrderKernelTestBase::setUp

File

modules/promotion/tests/src/Kernel/Plugin/Commerce/PromotionOffer/CombinationOfferTest.php, line 50

Class

CombinationOfferTest
Tests the combination offer plugin.

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',
  ]);
  $product_type = ProductType::create([
    'id' => 'test',
    'label' => 'Test',
    'variationType' => 'default',
  ]);
  $product_type
    ->save();
  $variation = ProductVariation::create([
    'type' => 'default',
    'sku' => strtolower($this
      ->randomMachineName()),
    'price' => [
      'number' => '10.00',
      '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' => [],
  ]);
}