diff --git a/.travis.yml b/.travis.yml index 8d42a57..e81546b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,15 +3,24 @@ language: php matrix: fast_finish: true include: - - php: 5.5 - php: 5.6 env: - - CODE_COVERAGE=true + - COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction" + - php: 5.6 + - php: 7.0 + env: + - COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction" - php: 7.0 + - php: 7.1 + env: + - COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction" + - php: 7.1 + env: + - CODE_COVERAGE=true install: - composer self-update - - composer update + - composer update $COMPOSER_FLAGS - composer info script: diff --git a/composer.json b/composer.json index ed8e002..239e7fe 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,10 @@ } ], "require": { - "php": "~5.5 || ~7.0", + "php": "^5.6 || ^7.0", "doctrine/common": "^2.6", "ramsey/uuid": "^3.1", - "symfony/event-dispatcher": "^2.6 || ^3.0", + "symfony/event-dispatcher": "^2.6 || ^3.4 || ^4.0", "mtdowling/cron-expression": "^1.1" }, "require-dev": { diff --git a/src/Task/Runner/TaskRunner.php b/src/Task/Runner/TaskRunner.php index 8b08817..1d93d30 100644 --- a/src/Task/Runner/TaskRunner.php +++ b/src/Task/Runner/TaskRunner.php @@ -208,7 +208,7 @@ private function finalize(TaskExecutionInterface $execution, $start) // invalid (clear in doctrine) after handling an execution. $execution = $this->taskExecutionRepository->findByUuid($execution->getUuid()); - if ($execution->getStatus() !== TaskStatus::PLANNED) { + if (TaskStatus::PLANNED !== $execution->getStatus()) { $execution->setEndTime(new \DateTime()); $execution->setDuration(microtime(true) - $start); } diff --git a/src/Task/Scheduler/TaskScheduler.php b/src/Task/Scheduler/TaskScheduler.php index e0142b6..c18c3f1 100644 --- a/src/Task/Scheduler/TaskScheduler.php +++ b/src/Task/Scheduler/TaskScheduler.php @@ -107,7 +107,7 @@ protected function scheduleTask(TaskInterface $task) return; } - if ($task->getInterval() === null && 0 < count($this->taskExecutionRepository->findByTask($task))) { + if (null === $task->getInterval() && 0 < count($this->taskExecutionRepository->findByTask($task))) { return; } diff --git a/src/Task/Storage/ArrayStorage/ArrayTaskExecutionRepository.php b/src/Task/Storage/ArrayStorage/ArrayTaskExecutionRepository.php index 6cc990b..ce271e5 100644 --- a/src/Task/Storage/ArrayStorage/ArrayTaskExecutionRepository.php +++ b/src/Task/Storage/ArrayStorage/ArrayTaskExecutionRepository.php @@ -89,7 +89,7 @@ function (TaskExecutionInterface $execution) use ($task) { } ); - if ($filtered->count() === 0) { + if (0 === $filtered->count()) { return; } @@ -107,7 +107,7 @@ function (TaskExecutionInterface $execution) use ($uuid) { } ); - if ($filtered->count() === 0) { + if (0 === $filtered->count()) { return; } @@ -153,7 +153,7 @@ public function findNextScheduled(\DateTime $dateTime = null, array $skippedExec $result = $this->taskExecutionCollection->filter( function (TaskExecutionInterface $execution) use ($dateTime, $skippedExecutions) { - return $execution->getStatus() === TaskStatus::PLANNED + return TaskStatus::PLANNED === $execution->getStatus() && $execution->getScheduleTime() < $dateTime && !in_array($execution->getUuid(), $skippedExecutions); } diff --git a/src/Task/Storage/ArrayStorage/ArrayTaskRepository.php b/src/Task/Storage/ArrayStorage/ArrayTaskRepository.php index 676f0b0..064ea31 100644 --- a/src/Task/Storage/ArrayStorage/ArrayTaskRepository.php +++ b/src/Task/Storage/ArrayStorage/ArrayTaskRepository.php @@ -106,7 +106,7 @@ public function findEndBeforeNow() return array_values( $this->taskCollection->filter( function (TaskInterface $task) use ($now) { - return $task->getLastExecution() === null || $task->getLastExecution() > $now; + return null === $task->getLastExecution() || $task->getLastExecution() > $now; } )->toArray() ); diff --git a/src/Task/TaskStatus.php b/src/Task/TaskStatus.php index 00bab7d..cd2f165 100644 --- a/src/Task/TaskStatus.php +++ b/src/Task/TaskStatus.php @@ -17,9 +17,13 @@ final class TaskStatus { const PLANNED = 'planned'; + const RUNNING = 'running'; + const COMPLETED = 'completed'; + const ABORTED = 'aborted'; + const FAILED = 'failed'; /** diff --git a/tests/Unit/Runner/PendingExecutionFinderTest.php b/tests/Unit/Runner/PendingExecutionFinderTest.php index 6f9f846..d2aae7f 100644 --- a/tests/Unit/Runner/PendingExecutionFinderTest.php +++ b/tests/Unit/Runner/PendingExecutionFinderTest.php @@ -24,6 +24,7 @@ class PendingExecutionFinderTest extends \PHPUnit_Framework_TestCase { const HANDLER = 'AppBundle\\Handler\\TestHandler'; + const LOCKING_HANDLER = 'AppBundle\\Handler\\LockingTestHandler'; /**