You are here

protected function WishlistItemTest::setUp in Commerce Wishlist 8.3

Same name in this branch
  1. 8.3 tests/src/Functional/WishlistItemTest.php \Drupal\Tests\commerce_wishlist\Functional\WishlistItemTest::setUp()
  2. 8.3 tests/src/Kernel/Entity/WishlistItemTest.php \Drupal\Tests\commerce_wishlist\Kernel\Entity\WishlistItemTest::setUp()

Overrides CommerceBrowserTestBase::setUp

File

tests/src/Functional/WishlistItemTest.php, line 48

Class

WishlistItemTest
Tests the wishlist item UI.

Namespace

Drupal\Tests\commerce_wishlist\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->wishList = $this
    ->createEntity('commerce_wishlist', [
    'type' => 'default',
    'name' => 'Secret gifts',
    'public' => TRUE,
    'keep_purchased_items' => TRUE,
  ]);
  $this->firstVariation = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'default',
    'sku' => 'S-DESK',
    'title' => 'Standing desk',
    'price' => new Price('120.00', 'USD'),
  ]);
  $this->secondVariation = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'default',
    'sku' => 'R-DESK',
    'title' => 'Regular desk',
    'price' => new Price('70.00', 'USD'),
  ]);
  $this
    ->createEntity('commerce_product', [
    'type' => 'default',
    'title' => $this
      ->randomMachineName(),
    'stores' => [
      $this->store,
    ],
    'variations' => [
      $this->firstVariation,
      $this->secondVariation,
    ],
  ]);
  $this->wishListItemCollectionUri = Url::fromRoute('entity.commerce_wishlist_item.collection', [
    'commerce_wishlist' => $this->wishList
      ->id(),
  ])
    ->toString();
}