You are here

function StatsproTestCase::testPosNavegationState in Statistics Pro 6

Same name and namespace in other branches
  1. 6.2 tests/statspro.test \StatsproTestCase::testPosNavegationState()

File

tests/statspro.test, line 675
Functionality tests for Statistics Pro.

Class

StatsproTestCase
Class resposible for testing the statspro class.

Code

function testPosNavegationState() {
  $this
    ->createInitialData();

  /**
   * Turning on the access logs.
   */
  $this
    ->drupalLogin($this->users['stats_admin']);
  $edit = array(
    'statistics_enable_access_log' => 1,
    'statistics_flush_accesslog_timer' => 9676800,
  );
  $this
    ->drupalPost('admin/reports/settings', $edit, t('Save configuration'));
  $this
    ->drupalLogout();

  // Anonymous user navigation.
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - now', array(
    '!this' => 1,
    '!total' => 1,
  )));
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - last week', array(
    '!this' => 2,
    '!total' => 2,
  )));
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - last year', array(
    '!this' => 2,
    '!total' => 3,
  )));

  // Asking for inexistent pages.
  $this
    ->drupalGet('node/111');
  $this
    ->drupalGet('node/1099');

  // Authenticated user nagivation.
  $this
    ->drupalLogin($this->users['regular_3']);
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - last week', array(
    '!this' => 2,
    '!total' => 2,
  )));
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - last month', array(
    '!this' => 1,
    '!total' => 1,
  )));
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - last week', array(
    '!this' => 1,
    '!total' => 2,
  )));
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - now', array(
    '!this' => 1,
    '!total' => 1,
  )));

  // Asking for inexistent pages.
  $this
    ->drupalGet('node/700');
  $this
    ->drupalGet('node/199');
  $this
    ->drupalLogin($this->users['regular_1']);
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - last week', array(
    '!this' => 1,
    '!total' => 2,
  )));
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - now', array(
    '!this' => 1,
    '!total' => 1,
  )));
  $this
    ->drupalGetNodeByTitle(t('Node !this/!total - last year', array(
    '!this' => 1,
    '!total' => 3,
  )));
  $this
    ->callCron();
  $group = t('General statspro class tests');

  /**
  * Absolute amounts: pi, upi, error, uerror, warning and uwarning.
  *

      /**
  * Besides the 10 get nodes above, Drupal produces 11 extra page impressions.
  */
  $correct = 10 + 11;
  $this
    ->completeTestAggregatedData('pi', $correct, $group);
  $this
    ->completeTestAggregatedData('upi', 10, $group);
  $this
    ->completeTestAggregatedData('error', 0, $group);
  $this
    ->completeTestAggregatedData('uerror', 0, $group);
  $this
    ->completeTestAggregatedData('warning', 4, $group);
  $this
    ->completeTestAggregatedData('uwarning', 2, $group);

  /**
   * Non-absolute amounts: users, terms, nodes, node_types, comments,
   * aliases, sessions and modules.
   */

  /**
   * Drupal already creates the "zero" user which is tne non-authenticated
   * user and saves the slot for the admin user so we have to add 2 to the
   * number of users we created up until now in the test.
   */
  $correct = 2 + count($this->users);
  $this
    ->completeTestAggregatedData('users', $correct, $group);
  $this
    ->completeTestAggregatedData('terms', 0, $group);
  $correct = count($this->node_titles);
  $this
    ->completeTestAggregatedData('nodes', $correct, $group);

  // Drupal already has 2 node types defined: page and story.
  $correct = 2;
  $this
    ->completeTestAggregatedData('node_types', $correct, $group);
  $this
    ->completeTestAggregatedData('comments', 0, $group);
  $this
    ->completeTestAggregatedData('aliases', 0, $group);
  $this
    ->completeTestAggregatedData('sessions', 1, $group);

  // The basic Drupal installation already has 11 modules enabled.
  $correct = 11 + count($this->modules);
  $this
    ->completeTestAggregatedData('modules', $correct, $group);
}