You are here

public function OptimizedbFunctionsTestCase::testCronClearTablePeriodTime in OptimizeDB 7

Testing, when set period of time clean-up table "cache_form" using Cron.

File

./optimizedb.test, line 156
Tests for optimizedb.module.

Class

OptimizedbFunctionsTestCase
Test the module functions.

Code

public function testCronClearTablePeriodTime() {
  variable_set('optimizedb_clear_period', 100);
  $current_hour = (int) date('H');
  foreach (range(0, 23, OPTIMIZEDB_CLEAR_PERIOD_STEP) as $time) {
    $period_time_start = $time - OPTIMIZEDB_CLEAR_PERIOD_STEP;
    if ($current_hour >= $period_time_start && $current_hour <= $time) {
      variable_set('optimizedb_clear_period_time', $time);
    }
  }
  $this
    ->createCacheFormItem();
  $this
    ->assertEqual($this
    ->countCacheFormRows(), 1);
  $this
    ->cronRun();
  $this
    ->assertEqual($this
    ->countCacheFormRows(), 0);
}