You are here

public function GoogleAnalyticsEventTrackingJsTest::setUp in Google Analytics Event Tracking 8

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/GoogleAnalyticsEventTrackingJsTest.php \Drupal\Tests\google_analytics_et\FunctionalJavascript\GoogleAnalyticsEventTrackingJsTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/GoogleAnalyticsEventTrackingJsTest.php, line 29

Class

GoogleAnalyticsEventTrackingJsTest
Google Analytics Event Tracking JavaScript tests.

Namespace

Drupal\Tests\google_analytics_et\FunctionalJavascript

Code

public function setUp() {
  parent::setUp();
  $this->container
    ->get('theme_installer')
    ->install([
    'bartik',
  ]);
  $this->container
    ->get('config.factory')
    ->getEditable('system.theme')
    ->set('default', 'bartik')
    ->save();

  // Set a fake account for GA so the script is added to the page.
  $this
    ->config('google_analytics.settings')
    ->set('account', 'UA-123456-1');

  // Create a test tracker config.
  GoogleAnalyticsEventTracker::create([
    'label' => 'test tracker',
    'id' => 'test_tracker',
    'element_selector' => '#edit-test-radios-two',
    'dom_event' => 'click',
    'ga_event_category' => 'test category',
    'ga_event_action' => 'test action',
    'ga_event_label' => 'test label',
    'ga_event_value' => 666,
    'ga_event_noninteraction' => 0,
  ]);
}