public writeToFile ( |
||
$crontab | ||
$filename | string | |
return |
public function writeToFile(Crontab $crontab, $filename)
{
if (!is_writable($filename)) {
throw new \InvalidArgumentException('File ' . $filename . ' is not writable.');
}
file_put_contents($filename, $crontab->render() . PHP_EOL);
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. }