function GoogleAnalyticsStatusMessagesTest::testGoogleAnalyticsStatusMessages in Google Analytics 6.4
Same name and namespace in other branches
- 7.2 googleanalytics.test \GoogleAnalyticsStatusMessagesTest::testGoogleAnalyticsStatusMessages()
- 7 googleanalytics.test \GoogleAnalyticsStatusMessagesTest::testGoogleAnalyticsStatusMessages()
File
- ./
googleanalytics.test, line 439 - Test file for Google Analytics module.
Class
Code
function testGoogleAnalyticsStatusMessages() {
$ua_code = 'UA-123456-4';
variable_set('googleanalytics_account', $ua_code);
// Enable logging of errors only.
variable_set('googleanalytics_trackmessages', array(
'error' => 'error',
));
$this
->drupalPost('user/login', array(), t('Log in'));
$this
->assertRaw('ga("send", "event", "Messages", "Error message", "Username field is required.");', '[testGoogleAnalyticsStatusMessages]: Event message "Username field is required." is shown.');
$this
->assertRaw('ga("send", "event", "Messages", "Error message", "Password field is required.");', '[testGoogleAnalyticsStatusMessages]: Event message "Password field is required." is shown.');
// @todo: investigate why drupal_set_message() fails.
//drupal_set_message('Example status message.', 'status');
//drupal_set_message('Example warning message.', 'warning');
//drupal_set_message('Example error message.', 'error');
//drupal_set_message('Example error <em>message</em> with html tags and <a href="https://example.com/">link</a>.', 'error');
//$this->drupalGet('');
//$this->assertNoRaw('ga("send", "event", "Messages", "Status message", "Example status message.");', '[testGoogleAnalyticsStatusMessages]: Example status message is not enabled for tracking.');
//$this->assertNoRaw('ga("send", "event", "Messages", "Warning message", "Example warning message.");', '[testGoogleAnalyticsStatusMessages]: Example warning message is not enabled for tracking.');
//$this->assertRaw('ga("send", "event", "Messages", "Error message", "Example error message.");', '[testGoogleAnalyticsStatusMessages]: Example error message is shown.');
//$this->assertRaw('ga("send", "event", "Messages", "Error message", "Example error message with html tags and link.");', '[testGoogleAnalyticsStatusMessages]: HTML has been stripped successful from Example error message with html tags and link.');
}