You are here

public function WishlistManagerTest::testAddEntity in Commerce Wishlist 8.3

Tests adding a purchasable entity to a wishlist.

@covers ::addEntity

File

tests/src/Kernel/WishlistManagerTest.php, line 119

Class

WishlistManagerTest
Tests the wishlist manager.

Namespace

Drupal\Tests\commerce_wishlist\Kernel

Code

public function testAddEntity() {
  $wishlist = Wishlist::create([
    'type' => 'test',
    'name' => 'My wishlist',
  ]);
  $wishlist
    ->save();
  $wishlist_item = $this->wishlistManager
    ->addEntity($wishlist, $this->productVariationFirst, 3);
  $this
    ->assertInstanceOf(WishlistItemInterface::class, $wishlist_item);
  $this
    ->assertEquals(3, $wishlist_item
    ->getQuantity());
  $this
    ->assertEquals('Product 1', $wishlist_item
    ->getTitle());
  $this
    ->assertTrue($wishlist
    ->hasItem($wishlist_item));
}