You are here

protected function PriceListRepositoryTest::setUp in Commerce Pricelist 8.2

Overrides PriceListKernelTestBase::setUp

File

tests/src/Kernel/PriceListRepositoryTest.php, line 45

Class

PriceListRepositoryTest
Tests the price list repository.

Namespace

Drupal\Tests\commerce_pricelist\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $variation = ProductVariation::create([
    'type' => 'default',
    'sku' => strtolower($this
      ->randomMachineName()),
    'title' => $this
      ->randomString(),
    'price' => new Price('8.00', 'USD'),
  ]);
  $variation
    ->save();
  $this->variation = $this
    ->reloadEntity($variation);
  $price_list = PriceList::create([
    'type' => 'commerce_product_variation',
    'stores' => [
      $this->store
        ->id(),
    ],
    'weight' => '1',
  ]);
  $price_list
    ->save();
  $price_list_item = PriceListItem::create([
    'type' => 'commerce_product_variation',
    'price_list_id' => $price_list
      ->id(),
    'purchasable_entity' => $variation
      ->id(),
    'quantity' => '1',
    'list_price' => new Price('7.70', 'USD'),
    'price' => new Price('5.00', 'USD'),
  ]);
  $price_list_item
    ->save();
  $this->priceList = $this
    ->reloadEntity($price_list);
  $this->priceListItem = $this
    ->reloadEntity($price_list_item);
}