You are here

public function WishlistManagerTest::testRemoveWishlistItem in Commerce Wishlist 8.3

Tests removing a wishlist item from a wishlist.

@covers ::removeWishlistItem

File

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

Class

WishlistManagerTest
Tests the wishlist manager.

Namespace

Drupal\Tests\commerce_wishlist\Kernel

Code

public function testRemoveWishlistItem() {
  $wishlist_item = WishlistItem::create([
    'type' => 'commerce_product_variation',
    'purchasable_entity' => $this->productVariationFirst,
  ]);
  $wishlist_item
    ->save();
  $wishlist = Wishlist::create([
    'type' => 'test',
    'wishlist_items' => [
      $wishlist_item,
    ],
    'name' => 'My wishlist',
  ]);
  $wishlist
    ->save();
  $this
    ->assertTrue($wishlist
    ->hasItems());
  $this->wishlistManager
    ->removeWishlistItem($wishlist, $wishlist_item);
  $this
    ->assertFalse($wishlist
    ->hasItems());
}