You are here

function MatomoStatusMessagesTest::testMatomoStatusMessages in Matomo Analytics 7.2

File

./matomo.test, line 383
Test file for Matomo module.

Class

MatomoStatusMessagesTest

Code

function testMatomoStatusMessages() {
  $ua_code = '1';
  variable_set('matomo_site_id', $ua_code);

  // Enable logging of errors only.
  variable_set('matomo_trackmessages', array(
    'error' => 'error',
  ));
  $this
    ->drupalPost('user/login', array(), t('Log in'));
  $this
    ->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Username field is required."]);', '[testMatomoStatusMessages]: trackEvent "Username field is required." is shown.');
  $this
    ->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Password field is required."]);', '[testMatomoStatusMessages]: trackEvent "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('_paq.push(["trackEvent", "Messages", "Status message", "Example status message."]);', '[testMatomoStatusMessages]: Example status message is not enabled for tracking.');

  //$this->assertNoRaw('_paq.push(["trackEvent", "Messages", "Warning message", "Example warning message."]);', '[testMatomoStatusMessages]: Example warning message is not enabled for tracking.');

  //$this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Example error message."]);', '[testMatomoStatusMessages]: Example error message is shown.');

  //$this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Example error message with html tags and link."]);', '[testMatomoStatusMessages]: HTML has been stripped successful from Example error message with html tags and link.');
}