You are here

protected function WishlistShareMailTest::setUp in Commerce Wishlist 8.3

Overrides WishlistKernelTestBase::setUp

File

tests/src/Kernel/Mail/WishlistShareMailTest.php, line 45

Class

WishlistShareMailTest
Tests the sending of wishlist share emails.

Namespace

Drupal\Tests\commerce_wishlist\Kernel\Mail

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->config('system.site')
    ->set('name', 'Drupal')
    ->save();
  $this->user = $this
    ->createUser([
    'mail' => 'customer@example.com',
  ]);
  $this->mail = $this->container
    ->get('commerce_wishlist.wishlist_share_mail');
  $variation = ProductVariation::create([
    'type' => 'default',
    'sku' => strtolower($this
      ->randomMachineName()),
    'price' => [
      'number' => 9.99,
      'currency_code' => 'USD',
    ],
  ]);
  $variation
    ->save();
  $wishlist_item = WishlistItem::create([
    'type' => 'commerce_product_variation',
    'purchasable_entity' => $variation,
    'quantity' => 1,
  ]);
  $wishlist_item
    ->save();
  $wishlist_item = $this
    ->reloadEntity($wishlist_item);
  $this->wishlist = Wishlist::create([
    'type' => 'default',
    'title' => 'My wishlist',
    'uid' => $this->user
      ->id(),
    'wishlist_items' => [
      $wishlist_item,
    ],
  ]);
  $this->wishlist
    ->save();
  $this->wishlist = $this
    ->reloadEntity($this->wishlist);
}