You are here

public function WishlistTest::testDelete in Commerce Wishlist 8.3

Tests deleting a wishlist.

File

tests/src/Functional/WishlistTest.php, line 178

Class

WishlistTest
Tests the wishlist UI.

Namespace

Drupal\Tests\commerce_wishlist\Functional

Code

public function testDelete() {
  $wishlist = $this
    ->createEntity('commerce_wishlist', [
    'type' => 'default',
    'name' => $this
      ->randomMachineName(8),
  ]);
  $this
    ->drupalGet($wishlist
    ->toUrl('delete-form'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('This action cannot be undone.');
  $this
    ->submitForm([], t('Delete'));
  \Drupal::service('entity_type.manager')
    ->getStorage('commerce_wishlist')
    ->resetCache([
    $wishlist
      ->id(),
  ]);
  $wishlist_exists = (bool) Wishlist::load($wishlist
    ->id());
  $this
    ->assertFalse($wishlist_exists);
}