markTestSkipped( 'The OS is not linux.' ); } } // * * * * * echo "test" > __DIR__ . '/cronjob.log' // evaluate dir /** * @testdox The cron handler has the expected default values after initialization * @covers phpOMS\Utils\TaskSchedule\Cron * @group framework */ public function testDefault() : void { self::assertInstanceOf('\phpOMS\Utils\TaskSchedule\SchedulerAbstract', new Cron()); } /** * @testdox The cron binary location path can be guessed * @covers phpOMS\Utils\TaskSchedule\Cron * @group framework */ public function testGuessBinary() : void { self::assertTrue(Cron::guessBin()); } /** * @testdox A cron job can be created and returned * @covers phpOMS\Utils\TaskSchedule\Cron * @group framework */ public function testCronJobInputOutput() : void { $cron = new Cron(); $job = new CronJob('testCronJob', 'testFile', '0 0 1 1 *'); $cron->create($job); self::assertTrue(!empty($cron->getAllByName('testCronJob', false))); if (!empty($cron->getAllByName('testCronJob', false))) { self::assertEquals('testFile', $cron->getAllByName('testCronJob', false)[0]->getCommand()); } $cron->delete($job); } /** * @testdox A none-existing cron name cannot be returned * @covers phpOMS\Utils\TaskSchedule\Cron * @group framework */ public function testInvalidCronJobName() : void { $cron = new Cron(); self::assertEquals([], $cron->getAllByName('testCronJob', false)); } /** * @testdox A cron job can be updated * @covers phpOMS\Utils\TaskSchedule\Cron * @group framework */ public function testCronJobUpdate() : void { $cron = new Cron(); $job = new CronJob('testCronJob', 'testFile', '0 0 1 1 *'); $cron->create($job); $job->setCommand('testFile2'); $cron->update($job); self::assertTrue(!empty($cron->getAllByName('testCronJob', false))); if (!empty($cron->getAllByName('testCronJob', false))) { self::assertEquals('testFile2', $cron->getAllByName('testCronJob', false)[0]->getCommand()); } $cron->delete($job); } /** * @testdox A cron job can be deleted * @covers phpOMS\Utils\TaskSchedule\Cron * @group framework */ public function testDelete() : void { $cron = new Cron(); $job = new CronJob('testCronJob', 'testFile', '0 0 1 1 *'); $cron->create($job); self::assertTrue(!empty($cron->getAllByName('testCronJob', false))); $cron->delete($job); self::assertEquals([], $cron->getAllByName('testCronJob', false)); } }