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 CommerceBrowserTestBase::setUp

File

tests/src/Functional/PriceListItemTest.php, line 69

Class

PriceListItemTest
Tests the price list item UI.

Namespace

Drupal\Tests\commerce_pricelist\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Turn off title generation to allow explicit values to be used.
  $variation_type = ProductVariationType::load('default');
  $variation_type
    ->setGenerateTitle(FALSE);
  $variation_type
    ->save();
  $this->priceList = $this
    ->createEntity('commerce_pricelist', [
    'type' => 'commerce_product_variation',
    'name' => $this
      ->randomMachineName(8),
    'start_date' => '2018-07-07',
  ]);
  $this->firstVariation = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'default',
    'sku' => 'RED-SHIRT',
    'title' => 'Red shirt',
    'price' => new Price('12.00', 'USD'),
  ]);
  $this->secondVariation = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'default',
    'sku' => 'BLUE-SHIRT',
    'title' => 'Blue shirt',
    'price' => new Price('11.00', 'USD'),
  ]);
  $this
    ->createEntity('commerce_product', [
    'type' => 'default',
    'title' => $this
      ->randomMachineName(),
    'stores' => [
      $this->store,
    ],
    'variations' => [
      $this->firstVariation,
      $this->secondVariation,
    ],
  ]);
  $this->priceListItemCollectionUri = Url::fromRoute('entity.commerce_pricelist_item.collection', [
    'commerce_pricelist' => $this->priceList
      ->id(),
  ])
    ->toString();
}