示例#1
0
 function test_replace_time()
 {
     $crontab = new Crontab($this->config);
     $time = '0 * * * *';
     $time_to = '0 12 * * *';
     $action = 'test_replace_time';
     $crontab->add_job($time, $action);
     $file_items = explode("\n", read_file($crontab->cronfile));
     $job = $time . ' ' . $crontab->php_path . ' ' . $crontab->cli_path . $action;
     $this->assertTrue(in_array($job, $file_items));
     //actual test
     $crontab->replace_time($time, $time_to, $action);
     $file_items = explode("\n", read_file($crontab->cronfile));
     $job = $time . ' ' . $crontab->php_path . ' ' . $crontab->cli_path . $action;
     $this->assertFalse(in_array($job, $file_items));
     $job = $time_to . ' ' . $crontab->php_path . ' ' . $crontab->cli_path . $action;
     $this->assertTrue(in_array($job, $file_items));
 }