You are here

public function WishlistAnonymousTest::setUp in Commerce Wishlist 8.3

Overrides CommerceWebDriverTestBase::setUp

File

tests/src/FunctionalJavascript/WishlistAnonymousTest.php, line 52

Class

WishlistAnonymousTest
Tests the wishlist anonymous access.

Namespace

Drupal\Tests\commerce_wishlist\FunctionalJavascript

Code

public function setUp() : void {
  parent::setUp();
  $form_display = EntityViewDisplay::load('commerce_product.default.default');
  $form_display
    ->setComponent('variations', [
    'type' => 'commerce_add_to_cart',
    'weight' => 1,
    'label' => 'hidden',
    'settings' => [
      'combine' => TRUE,
    ],
    'third_party_settings' => [
      'commerce_wishlist' => [
        'show_wishlist' => TRUE,
        'weight_wishlist' => 99,
        'label_wishlist' => 'Add to wishlist',
        'region' => 'content',
      ],
    ],
  ]);
  $form_display
    ->save();
  $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,
    ],
  ]);
}