You are here

function GoogleAnalyticsBasicTest::testGoogleAnalyticsConfiguration in Google Analytics 6.4

Same name and namespace in other branches
  1. 6.3 googleanalytics.test \GoogleAnalyticsBasicTest::testGoogleAnalyticsConfiguration()
  2. 7.2 googleanalytics.test \GoogleAnalyticsBasicTest::testGoogleAnalyticsConfiguration()
  3. 7 googleanalytics.test \GoogleAnalyticsBasicTest::testGoogleAnalyticsConfiguration()

File

./googleanalytics.test, line 31
Test file for Google Analytics module.

Class

GoogleAnalyticsBasicTest
@file Test file for Google Analytics module.

Code

function testGoogleAnalyticsConfiguration() {

  // Check if Configure link is available on 'Status Reports' page. NOTE: Link is only shown without UA code configured.
  // Requires 'administer site configuration' permission.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertRaw('admin/settings/googleanalytics', '[testGoogleAnalyticsConfiguration]: Configure link from Status Reports page to Google Analytics Settings page exists.');

  // Check for setting page's presence.
  $this
    ->drupalGet('admin/settings/googleanalytics');
  $this
    ->assertRaw(t('Web Property ID'), '[testGoogleAnalyticsConfiguration]: Settings page displayed.');

  // Check for account code validation.
  $edit['googleanalytics_account'] = $this
    ->randomName(2);
  $this
    ->drupalPost('admin/settings/googleanalytics', $edit, t('Save configuration'));
  $this
    ->assertRaw(t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.'), '[testGoogleAnalyticsConfiguration]: Invalid Web Property ID number validated.');
}