/** * @Given Crontab save will be called */ public function crontabSaveShouldBeCalled() { $command = "'crontab' '/tmp/.*'"; $content = ''; $this->currentCrontab =& $content; $content = '1'; $this->processBuilder->addCommand($command, function ($command) use(&$content) { if (preg_match("#'crontab' '(/tmp/.*)'#", $command, $matches)) { $content = file_get_contents($matches[1]); } }, 0); }
function it_allows_to_write($crontab) { $processBuilder = new FakeProcessBuilder(); $shouldBe = $this->defaultContent; $processBuilder->addCommand("'crontab' '(/var)?/tmp/.*'", function ($command) use($shouldBe) { if (preg_match("#'crontab' '((/var)?/tmp/.*)'#", $command, $matches)) { $content = file_get_contents($matches[1]); if ($content !== $shouldBe) { throw new FailureException("Content in not correct"); } } }, 1); Unix::setProcessBuilder($processBuilder); $this->write($crontab)->shouldReturn(true); Unix::setProcessBuilder(null); }