You are here

public function CartIntegrationTest::testRemovedFromCart in Commerce Core 8.2

Tests that a log is generated when an order is placed.

File

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

Class

CartIntegrationTest
Tests integration with cart events.

Namespace

Drupal\Tests\commerce_log\Kernel

Code

public function testRemovedFromCart() {
  $cart = $this->cartProvider
    ->createCart('default', $this->store, $this->user);
  $order_item = $this->cartManager
    ->addEntity($cart, $this->variation);
  $this->cartManager
    ->removeOrderItem($cart, $order_item);
  $logs = $this->logStorage
    ->loadMultipleByEntity($cart);
  $this
    ->assertEquals(2, count($logs));
  $log = end($logs);
  $build = $this->logViewBuilder
    ->view($log);
  $this
    ->render($build);
  $this
    ->assertText("{$this->variation->label()} removed from the cart.");
}