You are here

public function CartIntegrationTest::testAddedToCartNoPurchasableEntity in Commerce Core 8.2

Tests that a log is not generated when a non-purchasable entity added.

The cart manager does not fire the `CartEvents::CART_ENTITY_ADD` event unless there is a purchasable entity.

File

modules/log/tests/src/Kernel/CartIntegrationTest.php, line 101

Class

CartIntegrationTest
Tests integration with cart events.

Namespace

Drupal\Tests\commerce_log\Kernel

Code

public function testAddedToCartNoPurchasableEntity() {
  $cart = $this->cartProvider
    ->createCart('default', $this->store, $this->user);
  $order_item = OrderItem::create([
    'title' => 'Membership subscription',
    'type' => 'test',
    'quantity' => 1,
    'unit_price' => [
      'number' => '10.00',
      'currency_code' => 'USD',
    ],
  ]);
  $order_item
    ->save();
  $this->cartManager
    ->addOrderItem($cart, $order_item);
  $logs = $this->logStorage
    ->loadMultipleByEntity($cart);
  $this
    ->assertEquals(0, count($logs));
}