You are here

public function CartProviderTest::testCreateAuthenticatedCart in Commerce Core 8.2

Tests creating a cart for an authenticated user.

@covers ::createCart

File

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

Class

CartProviderTest
Tests the cart provider.

Namespace

Drupal\Tests\commerce_cart\Kernel

Code

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

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