From ed3fc48e346702c7fe1f4978799a7485ed93452a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 2 Aug 2018 18:45:36 +0200 Subject: [PATCH] fixes #26 --- Utils/TaskSchedule/SchedulerAbstract.php | 22 ++++++++++++++++++++++ tests/Utils/TaskSchedule/CronTest.php | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Utils/TaskSchedule/SchedulerAbstract.php b/Utils/TaskSchedule/SchedulerAbstract.php index 5b8a00126..2237e10ec 100644 --- a/Utils/TaskSchedule/SchedulerAbstract.php +++ b/Utils/TaskSchedule/SchedulerAbstract.php @@ -182,6 +182,28 @@ abstract class SchedulerAbstract $this->run($task->getCommand()); } + /** + * Update task + * + * @param TaskAbstract $task Task to update + * + * @return void + * + * @since 1.0.0 + */ + abstract public function update(TaskAbstract $task) : void; + + /** + * Delete task + * + * @param TaskAbstract $task Task to delete + * + * @return void + * + * @since 1.0.0 + */ + abstract public function delete(TaskAbstract $task) : void; + /** * Normalize run result for easier parsing * diff --git a/tests/Utils/TaskSchedule/CronTest.php b/tests/Utils/TaskSchedule/CronTest.php index d828b97ad..ee7035a95 100644 --- a/tests/Utils/TaskSchedule/CronTest.php +++ b/tests/Utils/TaskSchedule/CronTest.php @@ -14,6 +14,7 @@ namespace phpOMS\tests\Utils\TaskSchedule; use phpOMS\Utils\TaskSchedule\Cron; +use phpOMS\Utils\TaskSchedule\CronJob; class CronTest extends \PHPUnit\Framework\TestCase { @@ -21,4 +22,26 @@ class CronTest extends \PHPUnit\Framework\TestCase { self::assertInstanceOf('\phpOMS\Utils\TaskSchedule\SchedulerAbstract', new Cron()); } + + public function testCRUD() + { + $cron = new Cron(); + + self::assertInstanceOf('\phpOMS\Utils\TaskSchedule\NullCronJob', $cron->getAllByName('testCronJob', false)); + + $cron->create( + new CronJob('testCronJob', 'testFile') + ); + self::assertEquals('testFile', $cron->getRun()); + + $cron->update( + new CronJob('testCronJob', 'testFile2') + ); + self::assertEquals('testFile2', $cron->getRun()); + + $cron->delete( + new CronJob('testCronJob', 'testFile2') + ); + self::assertInstanceOf('\phpOMS\Utils\TaskSchedule\NullCronJob', $cron->getAllByName('testCronJob', false)); + } }