You are here

public function CartProviderTest::testCreateAnonymousCart in Commerce Core 8.2

Tests cart creation for an anonymous user.

@covers ::createCart

File

modules/cart/tests/src/Kernel/CartProviderTest.php, line 57

Class

CartProviderTest
Tests the cart provider.

Namespace

Drupal\Tests\commerce_cart\Kernel

Code

public function testCreateAnonymousCart() {
  $order_type = 'default';
  $cart = $this->cartProvider
    ->createCart($order_type, $this->store, $this->anonymousUser);
  $this
    ->assertInstanceOf(OrderInterface::class, $cart);

  // Trying to recreate the same cart should throw an exception.
  $this
    ->expectException(DuplicateCartException::class);
  $this->cartProvider
    ->createCart($order_type, $this->store, $this->anonymousUser);
}