You are here

public function EventTrackerServiceTest::testRemoveFromCart in Commerce Google Tag Manager 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/EventTrackerServiceTest.php \Drupal\Tests\commerce_google_tag_manager\Unit\EventTrackerServiceTest::testRemoveFromCart()

@covers ::removeFromCart

@dataProvider productVariationProvider

File

tests/src/Unit/EventTrackerServiceTest.php, line 206

Class

EventTrackerServiceTest
Tests for the EventTracker service.

Namespace

Drupal\Tests\commerce_google_tag_manager\Unit

Code

public function testRemoveFromCart($product_variation, $product_data) {
  $order_item = $this
    ->prophesize(OrderItemInterface::class);
  $order_item
    ->getPurchasedEntity()
    ->willReturn($product_variation);
  $order_item
    ->getTotalPrice()
    ->willReturn(new Price('50', 'CHF'));
  $this->eventStorage
    ->expects($this
    ->once())
    ->method('addEvent')
    ->with([
    'event' => EventTrackerService::EVENT_REMOVE_CART,
    'ecommerce' => [
      'remove' => [
        'products' => [
          array_merge($product_data, [
            'quantity' => 1,
          ]),
        ],
      ],
    ],
  ]);
  $this->eventTracker
    ->removeFromCart($order_item
    ->reveal(), 1);
}