You are here

protected function PriceListItemTest::setUp in Commerce Pricelist 8.2

Same name in this branch
  1. 8.2 tests/src/Functional/PriceListItemTest.php \Drupal\Tests\commerce_pricelist\Functional\PriceListItemTest::setUp()
  2. 8.2 tests/src/Kernel/Entity/PriceListItemTest.php \Drupal\Tests\commerce_pricelist\Kernel\Entity\PriceListItemTest::setUp()

Overrides PriceListKernelTestBase::setUp

File

tests/src/Kernel/Entity/PriceListItemTest.php, line 37

Class

PriceListItemTest
Tests the price list item entity.

Namespace

Drupal\Tests\commerce_pricelist\Kernel\Entity

Code

protected function setUp() : void {
  parent::setUp();
  $price_list = PriceList::create([
    'type' => 'commerce_product_variation',
    'name' => 'B2B pricing',
    'stores' => [
      $this->store
        ->id(),
    ],
  ]);
  $price_list
    ->save();
  $variation = ProductVariation::create([
    'type' => 'default',
    'sku' => 'TEST_' . strtolower($this
      ->randomMachineName()),
    'title' => $this
      ->randomString(),
    'status' => 1,
    'price' => new Price('12.00', 'USD'),
  ]);
  $variation
    ->save();
  $product = Product::create([
    'type' => 'default',
    'title' => 'Default testing product',
    'variations' => [
      $variation
        ->id(),
    ],
  ]);
  $product
    ->save();
  $this->priceList = $this
    ->reloadEntity($price_list);
  $this->variation = $this
    ->reloadEntity($variation);
}