summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2008-11-22 23:12:35 (GMT)
committer hass2008-11-22 23:12:35 (GMT)
commit27f4381f247d8c81fd34ae63bbd4c1ac8d82f74e (patch)
tree9ff1626ee0828813e87f1bbc3eb17ae4a8b0bf05
parent16b095203d9274e33aa72e9367251e5a1cd1571d (diff)
#315609: Update test's for simpletest 6.x-2.x
-rw-r--r--tests/googleanalytics_basic.test65
1 files changed, 34 insertions, 31 deletions
diff --git a/tests/googleanalytics_basic.test b/tests/googleanalytics_basic.test
index ff974f9..a5459cd 100644
--- a/tests/googleanalytics_basic.test
+++ b/tests/googleanalytics_basic.test
@@ -5,85 +5,88 @@
* @file
* Test file for Google Analytics module.
*/
-
-class GoogleAnalyticsBasicTest extends DrupalTestCase {
- protected $web_user;
-
- function get_info() {
- return array('name' => t('Google Analytics basic tests'), 'desc' => t('Test basic Google Analytics module functionality.'), 'group' => 'Google Analytics');
+class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
+
+ function getInfo() {
+ return array(
+ 'name' => t('Google Analytics basic tests'),
+ 'description' => t('Test basic Google Analytics module functionality.'),
+ 'group' => 'Google Analytics',
+ );
}
function setUp() {
- // User to set up google_analytics.
- $this->web_user = $this->drupalCreateUserRolePerm(array('administer google analytics'));
+ $permissions = array(
+ 'administer google analytics',
+ );
- $this->drupalGet('logout');
- $this->drupalLoginUser($this->web_user);
-
- parent::setUp();
+ // User to set up google_analytics.
+ $user = $this->drupalCreateUser($permissions);
+ $this->drupalLogin($user);
}
function testGoogleAnalytics() {
// Check for setting page's presence.
$this->drupalGet('admin/settings/googleanalytics');
- $this->assertWantedRaw(t('Google Analytics account number'), "[testGoogleAnalytics]: Settings page displayed");
+ $this->assertRaw(t('Google Analytics account number'), '[testGoogleAnalytics]: Settings page displayed.');
// Check for account code validation.
$edit['googleanalytics_account'] = $this->randomName(2);
$this->drupalPost('admin/settings/googleanalytics', $edit, 'Save configuration');
- $this->assertWantedRaw(t('A valid Google Analytics account number is case sensitive and formated like UA-xxxxxx-x.'), "[testGoogleAnalytics]: Account number validated");
+ $this->assertRaw(t('A valid Google Analytics account number is case sensitive and formated like UA-xxxxxx-x.'), '[testGoogleAnalytics]: Account number validated.');
}
function testGoogleAnalyticsTracking() {
// Set visibility to hide tracking code on admin page only,
// track authenticated users.
- $this->drupalVariableSet('googleanalytics_visibility', 0);
- $this->drupalVariableSet('googleanalytics_pages', "admin*");
- $this->drupalVariableSet('googleanalytics_roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
+ variable_set('googleanalytics_visibility', 0);
+ variable_set('googleanalytics_pages', 'admin*');
+ variable_set('googleanalytics_roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
$ua_code = 'UA-123456-7';
- $this->drupalVariableSet('googleanalytics_account', $ua_code);
+ variable_set('googleanalytics_account', $ua_code);
// Check tracking code visibility.
$this->drupalGet('');
- $this->assertWantedRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is displayed for authenticated');
+ $this->assertRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is displayed for authenticated.');
/* Sample JS code as added to page:
<script type="text/javascript" src="/sites/all/modules/google_analytics/googleanalytics.js?w"></script>
<script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script>
- <script type="text/javascript">var pageTracker = _gat._getTracker("UA-123456-7");pageTracker._initData();pageTracker._trackPageview();</script>
+ <script type="text/javascript">var pageTracker = _gat._getTracker("UA-123456-7");pageTracker._trackPageview();</script>
*/
// Test whether tracking code uses latest JS.
- $this->drupalVariableSet('googleanalytics_legacy_version', 0);
+ variable_set('googleanalytics_cache', 0);
+ variable_set('googleanalytics_legacy_version', 0);
$this->drupalGet('');
- $this->assertWantedRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsTracking]: Latest tracking code used');
+ $this->assertRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsTracking]: Latest tracking code used.');
// Test whether tracking code uses legacy JS.
- $this->drupalVariableSet('googleanalytics_legacy_version', 1);
+ variable_set('googleanalytics_legacy_version', 1);
$this->drupalGet('');
- $this->assertWantedRaw('google-analytics.com/urchin.js', '[testGoogleAnalyticsTracking]: Legacy tracking code used');
+ $this->assertRaw('google-analytics.com/urchin.js', '[testGoogleAnalyticsTracking]: Legacy tracking code used.');
// Test whether tracking code is not included on pages to omit.
$this->drupalGet('admin');
- $this->assertNoUnWantedRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is not displayed on admin page');
+ $this->assertNoRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is not displayed on admin page.');
$this->drupalGet('admin/settings/googleanalytics');
// Checking for tracking code URI here, as $ua_code is displayed in the form.
- $this->assertNoUnWantedRaw('google-analytics.com/urchin.js', '[testGoogleAnalyticsTracking]: Tracking code is not displayed on admin subpage');
+ $this->assertNoRaw('google-analytics.com/urchin.js', '[testGoogleAnalyticsTracking]: Tracking code is not displayed on admin subpage.');
// Test whether tracking code display is properly flipped.
- $this->drupalVariableSet('googleanalytics_visibility', 1);
+ variable_set('googleanalytics_visibility', 1);
$this->drupalGet('admin');
- $this->assertWantedRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is displayed on admin page');
+ $this->assertRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is displayed on admin page.');
$this->drupalGet('admin/settings/googleanalytics');
// Checking for tracking code URI here, as $ua_code is displayed in the form.
- $this->assertWantedRaw('google-analytics.com/urchin.js', '[testGoogleAnalyticsTracking]: Tracking code is displayed on admin subpage');
+ $this->assertRaw('google-analytics.com/urchin.js', '[testGoogleAnalyticsTracking]: Tracking code is displayed on admin subpage.');
$this->drupalGet('');
- $this->assertNoUnWantedRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is not displayed on front page');
+ $this->assertNoRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is not displayed on front page.');
// Test whether tracking code is not display for anonymous.
$this->drupalGet('logout');
$this->drupalGet('');
- $this->assertNoUnWantedRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is not displayed for anonymous');
+ $this->assertNoRaw($ua_code, '[testGoogleAnalyticsTracking]: Tracking code is not displayed for anonymous.');
}
}