/** * @test */ public function shouldReplaceKeyIfExist() { $this->manipulatorStub->contents = <<<CRON headers # KEY key1 value 1 # END no key # KEY key2 # must be replaced # END # KEY key3 foo # END CRON; $cron = new Cron(); $cron->comment('replace'); $this->updater->updateWith($cron, 'key2'); $expectedCron = <<<CRON headers # KEY key1 value 1 # END no key # KEY key2 #replace # END # KEY key3 foo # END CRON; $this->assertEquals($expectedCron, $this->manipulatorStub->contents); }
/** * Create and configure Cron * * @return CronFormatter */ private function createCronConfiguration() { $cron = new CronFormatter(); $configurator = new ArrayHeaderConfigurator($cron->header()); $configurator->configureFrom($this->config); return $cron; }
private function wrapInKey(Cron $cron, $key) { return PHP_EOL . $this->beginKey($key) . PHP_EOL . trim($cron->format()) . PHP_EOL . self::KEY_END; }