You are here

public function ProductDetailViewsTest::testMissingDefaultVariation in Commerce Google Tag Manager 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/ProductDetailViewsTest.php \Drupal\Tests\commerce_google_tag_manager\Functional\ProductDetailViewsTest::testMissingDefaultVariation()

@covers ::trackProductView

Test that the module does not track the productDetailViews event if no default variation exists.

File

tests/src/Functional/ProductDetailViewsTest.php, line 103

Class

ProductDetailViewsTest
@coversDefaultClass \Drupal\commerce_google_tag_manager\EventSubscriber\CommerceEventsSubscriber

Namespace

Drupal\Tests\commerce_google_tag_manager\Functional

Code

public function testMissingDefaultVariation() {
  $this->product->variations = [];
  $this->product
    ->save();
  $this
    ->drupalGet($this->product
    ->toUrl()
    ->toString());
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $events = $this->tempStore
    ->get('events');
  $this
    ->assertNull($events);
}