Permalink
Browse files

Revert "MDL-30643 - Updated test cases to handle timezones better."

This reverts commit f0f0fec.
  • Loading branch information...
1 parent 447721b commit fa4fbd9790f81f9351f8d313f7b6be6ba4832cca @stronk7 stronk7 committed Sep 5, 2012
Showing with 28 additions and 53 deletions.
  1. +28 −53 lib/tests/statslib_test.php
@@ -44,7 +44,6 @@ protected function setUp() {
parent::setUp();
// Settings to force statistic to run during testing
- $CFG->timezone = 99;
$CFG->statsfirstrun = 'all';
$CFG->statslastdaily = 0;
$CFG->statslastexecution = 0;
@@ -128,9 +127,8 @@ public function daily_log_provider() {
$guest = $CFG->siteguest;
$user1 = $guest + 1;
$user2 = $user1 + 1;
- $start = stats_get_base_daily(1272758400);
- $end = stats_get_next_day_start($start);
- $fpid = (int) $CFG->defaultfrontpageroleid;
+ $end = 1272772800;
+ $fpid = (int)$CFG->defaultfrontpageroleid;
$gr = get_guest_role();
$stid = 5;
$nologend = stats_get_next_day_start(stats_get_base_daily(stats_get_start_from('daily')));
@@ -164,7 +162,7 @@ public function daily_log_provider() {
array( // Logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $guest,
'course' => SITEID,
'action' => 'view'
@@ -255,7 +253,7 @@ public function daily_log_provider() {
array( // Logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $user1,
'course' => SITEID,
'action' => 'login'
@@ -347,14 +345,14 @@ public function daily_log_provider() {
array( // logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $guest,
'course' => SITEID,
'action' => 'login'
),
array(
'id' => 2,
- 'time' => $start + 14420,
+ 'time' => 1272686420,
'userid' => $guest,
'course' => $course1,
'action' => 'view'
@@ -471,21 +469,21 @@ public function daily_log_provider() {
array( // logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $guest,
'course' => SITEID,
'action' => 'login'
),
array(
'id' => 2,
- 'time' => $start + 14420,
+ 'time' => 1272686420,
'userid' => $guest,
'course' => $course1,
'action' => 'view'
),
array(
'id' => 3,
- 'time' => $start + 14430,
+ 'time' => 1272686430,
'userid' => $guest,
'course' => $course1,
'action' => 'add post'
@@ -602,14 +600,14 @@ public function daily_log_provider() {
array( // logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $user1,
'course' => SITEID,
'action' => 'login'
),
array(
'id' => 2,
- 'time' => $start + 14420,
+ 'time' => 1272686420,
'userid' => $user1,
'course' => $course1,
'action' => 'view'
@@ -726,21 +724,21 @@ public function daily_log_provider() {
array( // logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $user1,
'course' => SITEID,
'action' => 'login'
),
array(
'id' => 2,
- 'time' => $start + 14420,
+ 'time' => 1272686420,
'userid' => $user1,
'course' => $course1,
'action' => 'view'
),
array(
'id' => 3,
- 'time' => $start + 14430,
+ 'time' => 1272686430,
'userid' => $user1,
'course' => $course1,
'action' => 'add post'
@@ -857,21 +855,21 @@ public function daily_log_provider() {
array( // logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $user2,
'course' => SITEID,
'action' => 'login'
),
array(
'id' => 2,
- 'time' => $start + 14420,
+ 'time' => 1272686420,
'userid' => $user2,
'course' => SITEID,
'action' => 'view'
),
array(
'id' => 3,
- 'time' => $start + 14430,
+ 'time' => 1272686430,
'userid' => $user2,
'course' => $course1,
'action' => 'view'
@@ -996,14 +994,14 @@ public function daily_log_provider() {
array( // logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $user1,
'course' => SITEID,
'action' => 'login'
),
array(
'id' => 2,
- 'time' => $start + 14420,
+ 'time' => 1272686420,
'userid' => $user1,
'course' => SITEID,
'action' => 'view'
@@ -1179,7 +1177,7 @@ public function test_statslib_get_start_from() {
$stats = array( // stats_daily
'courseid' => SITEID,
- 'timeend' => 1272758400,
+ 'timeend' => 1272772800,
'roleid' => 0,
'stattype' => 'logins',
'stat1' => 1,
@@ -1201,7 +1199,7 @@ public function test_statslib_get_start_from() {
$this->assertLessThanOrEqual(1, stats_get_start_from('daily') - ($time - (14515200)));
$DB->insert_record_raw('stats_daily', $stats);
- $this->assertEquals(1272758400, stats_get_start_from('daily'));
+ $this->assertEquals(1272772800, stats_get_start_from('daily'));
}
/**
@@ -1210,8 +1208,8 @@ public function test_statslib_get_start_from() {
public function test_statslib_get_base_daily() {
global $CFG;
- $CFG->timezone = 0;
- $this->assertEquals(1272672000, stats_get_base_daily(1272686410));
+ $CFG->timezone = 99;
+ $this->assertEquals(1272686400, stats_get_base_daily(1272686410));
$CFG->timezone = 5;
$this->assertEquals(1272654000, stats_get_base_daily(1272686410));
}
@@ -1220,10 +1218,7 @@ public function test_statslib_get_base_daily() {
* Test the function that gets the start of the next day
*/
public function test_statslib_get_next_day_start() {
- global $CFG;
-
- $CFG->timezone = 0;
- $this->assertEquals(1272758400, stats_get_next_day_start(1272686410));
+ $this->assertEquals(1272772800, stats_get_next_day_start(1272686410));
}
/**
@@ -1367,28 +1362,13 @@ public function test_statslib_temp_table_fill() {
$this->prepare_db($logs);
stats_temp_table_create();
- stats_temp_table_fill(1272686410, 1272758400);
+ stats_temp_table_fill(1272686410, 1272772800);
$this->assertEquals(1, $DB->count_records('temp_log1'));
$this->assertEquals(1, $DB->count_records('temp_log2'));
}
/**
- * Test the temporary table creation and deletion.
- */
- public function test_statslib_temp_table_setup() {
- global $DB;
-
- $logs = array();
- $this->prepare_db($logs);
-
- stats_temp_table_create();
- stats_temp_table_setup();
-
- $this->assertEquals(1, $DB->count_records('temp_enroled'));
- }
-
- /**
* Test the function that clean out the temporary tables.
*/
public function test_statslib_temp_table_clean() {
@@ -1421,8 +1401,6 @@ public function test_statslib_temp_table_clean() {
/**
* Test the daily stats function
*
- * @depends test_statslib_get_base_daily
- * @depends test_statslib_get_next_day_start
* @dataProvider daily_log_provider
*/
public function test_statslib_cron_daily($logs, $stats) {
@@ -1434,33 +1412,30 @@ public function test_statslib_cron_daily($logs, $stats) {
// Stats cron daily uses mtrace, turn on buffering to silence output.
ob_start();
- stats_cron_daily(1);
+ stats_cron_daily($maxdays=1);
ob_end_clean();
$this->verify_stats($stats);
}
/**
* Test the daily stats function
- * @depends test_statslib_get_base_daily
- * @depends test_statslib_get_next_day_start
*/
public function test_statslib_cron_daily_no_default_profile_id() {
global $CFG;
$CFG->defaultfrontpageroleid = 0;
$course1 = SITEID + 1;
$guest = $CFG->siteguest;
- $start = stats_get_base_daily(1272758400);
- $end = stats_get_next_day_start($start);
+ $end = 1272772800;
$stid = 5;
$fpid = 0;
$gr = get_guest_role();
$logs = array( // Logs
array(
'id' => 1,
- 'time' => $start + 14410,
+ 'time' => 1272686410,
'userid' => $guest,
'course' => SITEID,
'action' => 'view'

0 comments on commit fa4fbd9

Please sign in to comment.