You are here

public function EventTrackerServiceTest::testCheckoutStep 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::testCheckoutStep()

@covers ::checkoutStep

@dataProvider productVariationProvider

File

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

Class

EventTrackerServiceTest
Tests for the EventTracker service.

Namespace

Drupal\Tests\commerce_google_tag_manager\Unit

Code

public function testCheckoutStep($product_variation, $product_data) {
  $order_item = $this
    ->prohesizeOrderItem($product_variation, new Price('50', 'CHF'), '6.00');
  $order = $this
    ->prohesizeOrder([
    $order_item
      ->reveal(),
  ], 123, 'My Shop', new Price('50', 'CHF'));
  $this->eventStorage
    ->expects($this
    ->once())
    ->method('addEvent')
    ->with([
    'event' => EventTrackerService::EVENT_CHECKOUT,
    'ecommerce' => [
      'checkout' => [
        'actionField' => [
          'step' => 2,
        ],
        'products' => [
          array_merge($product_data, [
            'quantity' => 6,
          ]),
        ],
      ],
    ],
  ]);
  $this->eventTracker
    ->checkoutStep(2, $order
    ->reveal());
}