render() public method

Render the crontab and associated jobs
public render ( ) : string
return string
 public function testWriteToFileIsSuccessfulWhenFileIsWritable()
 {
     $this->crontabFileHandler->parseFromFile($this->crontab, $this->fixturesDir . '/crontab');
     $file = tempnam(sys_get_temp_dir(), 'cron');
     $this->crontabFileHandler->writeToFile($this->crontab, $file);
     $this->assertSame($this->crontab->render() . PHP_EOL, file_get_contents($file));
     unlink($file);
 }
Exemplo n.º 2
0
 /**
  * Write the current crons to a file.
  *
  * @param Crontab $crontab
  * @param string  $filename
  *
  * @return CrontabFileHandler
  * @throws \InvalidArgumentException
  */
 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;
 }
Exemplo n.º 3
0
 public function testWriteToFileIsSuccessfulWhenFileIsWritable()
 {
     $this->crontabFileHandler->parseFromFile($this->crontab, $this->fixtureFile);
     $this->crontabFileHandler->writeToFile($this->crontab, $this->tempFile);
     $this->assertSame($this->crontab->render() . PHP_EOL, file_get_contents($this->tempFile));
 }
Exemplo n.º 4
0
 public function render()
 {
     $description = implode(PHP_EOL, array("# AUTO GENERATED BY CRONMONITOR", "# PLEASE DON'T EDIT ANYTHING"));
     $result = sprintf("%s%s%s", $description, PHP_EOL, parent::render());
     return $result;
 }