You are here

public function WishlistUserTest::setUp in Commerce Wishlist 8.3

Overrides CommerceWebDriverTestBase::setUp

File

tests/src/FunctionalJavascript/WishlistUserTest.php, line 49

Class

WishlistUserTest
Tests the wishlist user pages.

Namespace

Drupal\Tests\commerce_wishlist\FunctionalJavascript

Code

public function setUp() : void {
  parent::setUp();
  $this
    ->createEntity('commerce_product_variation_type', [
    'id' => 'test',
    'label' => 'Test',
    'orderItemType' => 'default',
    'generateTitle' => FALSE,
  ]);
  $entity_display = commerce_get_entity_display('commerce_product_variation', 'test', 'view');
  $entity_display
    ->setComponent('title', [
    'label' => 'above',
    'type' => 'string',
  ]);
  $entity_display
    ->save();
  $this->variation1 = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'test',
    'title' => 'First variation',
    'sku' => strtolower($this
      ->randomMachineName()),
    'price' => [
      'number' => 9.99,
      'currency_code' => 'USD',
    ],
  ]);
  $this->variation2 = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'test',
    'title' => 'Second variation',
    'sku' => strtolower($this
      ->randomMachineName()),
    'price' => [
      'number' => 20.99,
      'currency_code' => 'USD',
    ],
  ]);

  /** @var \Drupal\commerce_product\Entity\ProductInterface $product */
  $this
    ->createEntity('commerce_product', [
    'type' => 'default',
    'title' => 'My product',
    'variations' => [
      $this->variation1,
      $this->variation2,
    ],
    'stores' => [
      $this->store,
    ],
  ]);
  $this->wishlist = $this
    ->createEntity('commerce_wishlist', [
    'type' => 'default',
    'title' => 'My wishlist',
    'uid' => $this->adminUser
      ->id(),
  ]);
}