function let(Crontab $crontab, Task $nmTask1, Task $nmTask2, Task $task1, Task $task2, Variables $variables1) { $this->prepareTask($task1, $variables1); $this->prepareTask($task2, $variables1); $this->prepareTask($nmTask1, $variables1, true); $this->prepareTask($nmTask2, $variables1, true); $crontab->getName()->willReturn("TestAopTest"); $crontab->getManagedTasks()->willReturn(array($task1, $task2)); $crontab->getNotManagedTasks()->willReturn(array($nmTask1, $nmTask2)); }
/** * @param OutputInterface $output * @param Crontab $crontab * @param string|null $user * * @return mixed */ public function output(OutputInterface $output, Crontab $crontab, $user = null) { $writer = new SystemWriter(array('user' => $user)); //Checking if we do want to save something if not it's better to left file as is if ($crontab->getManagedTasks()) { $writer->write($crontab); $output->writeln('Your crontab has been updated!'); } else { $output->writeln('Your crontab does not need to be updated!'); } }
function it_works_with_crons_without_comments(Task $taskWC, Variables $variablesWC, Crontab $crontabWC) { $this->prepareTask($taskWC, $variablesWC, true, false); $variablesWC->current()->willReturn('value'); $variablesWC->key()->willReturn('key'); $variablesWC->rewind()->shouldBeCalled(); $variablesWC->valid()->willReturn(true, false); $variablesWC->next()->shouldBeCalled(); $crontabWC->getName()->willReturn("TestAopTest"); $crontabWC->getManagedTasks()->willReturn(array($taskWC)); $crontabWC->getNotManagedTasks()->willReturn(array()); // echo($this->getContent($crontabWC)->getWrappedObject()); // die(); $this->getContent($crontabWC)->shouldReturn(<<<CONTENT #WARNING!!! #This crontab file it at least partially managed by Crontab by Hexmedia, please check all restrictions that comes with that library at: https://github.com/Hexmedia/Crontab/blob/master/README.md #EOT # ------------ CURRENTLY MANAGED by TestAopTest -------------- key=value */10 * * * * test > some_log_file.log CONTENT ); }