parseFromFile() публичный Метод

Reads cron jobs from a file.
public parseFromFile ( Crontab $crontab, string $filename ) : CrontabFileHandler
$crontab Crontab
$filename string
Результат CrontabFileHandler
Пример #1
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testWriteToFileThrowsExceptionWhenFileIsNotWritable()
 {
     $this->crontabFileHandler->parseFromFile($this->crontab, $this->fixtureFile);
     touch($this->tempFile);
     chmod($this->tempFile, 0400);
     $this->crontabFileHandler->writeToFile($this->crontab, $this->tempFile);
     // Expected an InvalidArgumentException because the file is not writable.
 }
Пример #2
0
 /**
  * Loads cronjobs form file
  *
  * @param string path to file
  * @return $this
  */
 public function loadFromFile($file)
 {
     $file = realpath($file);
     if (!$file) {
         throw new \InvalidArgumentException("File: {$file} not found");
     }
     $this->crontabFileHandler->parseFromFile($this->crontab, $file);
     return $this;
 }
 public function testWriteToFileThrowsExceptionWhenFileIsNotWritable()
 {
     $fail = true;
     $this->crontabFileHandler->parseFromFile($this->crontab, $this->fixturesDir . '/crontab');
     $file = tempnam(sys_get_temp_dir(), 'cron');
     touch($file);
     chmod($file, 0400);
     try {
         // We cannot use @expectedException annotation,
         // because we have to remove the temp file afterwards.
         $this->crontabFileHandler->writeToFile($this->crontab, $file);
     } catch (\InvalidArgumentException $e) {
         $fail = false;
     }
     chmod($file, 0600);
     unlink($file);
     if ($fail) {
         $this->fail('Expected an InvalidArgumentException because the file is not writable.');
     }
 }