public parseFromFile ( |
||
$crontab | ||
$filename | string | |
return |
public function parseFromFile(Crontab $crontab, $filename)
{
if (!is_readable($filename)) {
throw new \InvalidArgumentException('File ' . $filename . ' is not readable.');
}
$file = file_get_contents($filename);
foreach ($this->parseString($file) as $element) {
$crontab->addItem($element);
}
return $this;
}
/** * @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. }