function StatisticsProTestCase::testMainTests in Statistics Pro 6.2
Same name and namespace in other branches
- 6 tests/statspro.test \StatisticsProTestCase::testMainTests()
File
- tests/statspro.test, line 346
- Functionality tests for Statistics Pro.
Class
- StatisticsProTestCase
- Class responsible for testing the module.
Code
function testMainTests() {
$this
->createInitialData();
$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();
$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,
)));
$this
->drupalGet('node/111');
$this
->drupalGet('node/1099');
$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,
)));
$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 Statistics Pro tests');
$periods = statspro_get_period_items();
$this
->drupalLogin($this->users['stats']);
$period = 'today';
$texts = array(
'User registrations8',
'User online7',
'New nodes1',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, FALSE, FALSE);
$period = 'yesterday';
$texts = array(
'User registrations0',
'User online0',
'New nodes1',
'Changed nodes0',
'Comments0',
'No access and log files available for specified period.',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 2;
$texts = array(
'User registrations8',
'User online7',
'New nodes2',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 5;
$texts = array(
'User registrations8',
'User online7',
'New nodes3',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 7;
$texts = array(
'User registrations8',
'User online7',
'New nodes4',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 15;
$texts = array(
'User registrations8',
'User online7',
'New nodes5',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 45;
$texts = array(
'User registrations8',
'User online7',
'New nodes6',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 183;
$texts = array(
'User registrations8',
'User online7',
'New nodes7',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 315;
$texts = array(
'User registrations8',
'User online7',
'New nodes8',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$period = 1000;
$texts = array(
'User registrations8',
'User online7',
'New nodes8',
'Changed nodes0',
'Comments0',
'Page impressions21',
'Page impressions for authenticated users10',
'Errors0',
'Errors for authenticated users0',
'Warnings4',
'Warnings for authenticated users2',
'Emergencies0',
'Emergencies for authenticated users0',
'Alerts0',
'Alerts for authenticated users0',
'Critical conditions0',
'Critical conditions for authenticated users0',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, $period, $group);
$texts = array(
'Overview for new created comments.',
'Date',
'Comments',
'Trend',
'Amount',
);
$result = db_query('SELECT day FROM {statspro}');
while ($row = db_fetch_array($result)) {
$texts[] = $row['day'];
}
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/reports/statspro/comment', FALSE);
$texts = array(
'Overview for warnings.',
'Overview for warnings, registered users only.',
'Date',
'Trend',
'Amount',
);
$result = db_query('SELECT day
FROM {statspro}
WHERE error > 0
OR uerror > 0
OR warning > 0
OR uwarning > 0');
while ($row = db_fetch_array($result)) {
$texts[] = $row['day'];
}
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/reports/statspro/log', FALSE);
$texts = array(
'Overview for new created nodes.',
'Overview for changed nodes.',
'Date',
'Trend',
'Amount',
'New nodes',
'Changed nodes',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/reports/statspro/node', FALSE);
$texts = array(
'Page impressions for guests and registered users.',
'Page impressions registered users.',
'Date',
'Trend',
'Amount',
'Page impressions',
'Page impressions, users',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/reports/statspro/pi', FALSE);
$texts = array(
'Overview for new user registrations.',
'Overview for online user activity.',
'Date',
'Trend',
'Amount',
'User registrations',
'User online',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/reports/statspro/user', FALSE);
$this
->drupalLogout();
$this
->drupalGet('node/1');
$this
->drupalGet('node/4');
$this
->drupalGet('node/5');
$this
->drupalGet('node/6');
$this
->drupalGet('node/7');
$this
->drupalGet('node/8');
$this
->drupalLogin($this->users['regular_2']);
$this
->drupalGet('node/1');
$this
->drupalGet('node/2');
$this
->drupalGet('node/3');
$this
->drupalGet('node/4');
$this
->drupalGet('node/5');
$this
->drupalLogin($this->users['regular_3']);
$this
->drupalGet('node/4');
$this
->drupalGet('node/5');
$this
->drupalGet('node/6');
$this
->drupalGet('node/7');
$this
->drupalGet('node/8');
$this
->drupalLogin($this->users['stats_admin']);
$aggregators = array();
$texts = array(
'No path aggregators defined.',
);
$raws = array();
$group = 'Path aggregated';
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/settings/statspro/path_aggregator/list', FALSE);
$aggregator_name = 'Aggregator 1';
$aggregators[] = $aggregator_name;
$edit = array(
'name' => $aggregator_name,
'paths' => "node/1\nnode/3",
);
$this
->drupalPost('admin/settings/statspro/path_aggregator/add', $edit, t('Add'));
$this
->assertText($aggregator_name, t('New path aggregator %name created.', array(
'%name' => $aggregator_name,
)), $group);
$aggregator_name = 'Aggregator 2';
$aggregators[] = $aggregator_name;
$edit = array(
'name' => $aggregator_name,
'paths' => "node/2\nnode/4",
);
$this
->drupalPost('admin/settings/statspro/path_aggregator/add', $edit, t('Add'));
$this
->assertText($aggregator_name, t('New path aggregator %name created.', array(
'%name' => $aggregator_name,
)), $group);
$aggregator_name = 'Aggregator even';
$aggregators[] = $aggregator_name;
$edit = array(
'name' => $aggregator_name,
'paths' => "node/2\nnode/4\nnode/6\nnode/8",
);
$this
->drupalPost('admin/settings/statspro/path_aggregator/add', $edit, t('Add'));
$this
->assertText($aggregator_name, t('New path aggregator %name created.', array(
'%name' => $aggregator_name,
)), $group);
$aggregator_name = 'Aggregator odd';
$aggregators[] = $aggregator_name;
$edit = array(
'name' => $aggregator_name,
'paths' => "node/1\nnode/3\nnode/5\nnode/7",
);
$this
->drupalPost('admin/settings/statspro/path_aggregator/add', $edit, t('Add'));
$this
->assertText($aggregator_name, t('New path aggregator %name created.', array(
'%name' => $aggregator_name,
)), $group);
$texts = $aggregators;
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/settings/statspro/path_aggregator/list', FALSE);
$this
->drupalLogin($this->users['stats']);
$texts = array(
'Aggregator 1321',
'Aggregator 2431',
'Aggregator even421',
'Aggregator odd531',
);
$raws = array();
$this
->completeTestStatsHasTexts($texts, $raws, FALSE, $group, 'admin/reports/statspro/path_aggregated', FALSE);
$this
->drupalLogin($this->users['stats_admin']);
$edit = array();
$this
->drupalPost('admin/settings/statspro/path_aggregator/delete/3', $edit, 'Delete');
$texts = array(
'Aggregator 1',
'Aggregator 2',
'Aggregator odd',
);
foreach ($texts as $text) {
$this
->assertText($text, t('Text %text found on page.', array(
'%text' => $text,
)), $group);
}
$text = 'Aggregator even';
$this
->assertNoText($text, t('Text %text not found on page.', array(
'%text' => $text,
)), $group);
}