diff --git a/.gitignore b/.gitignore index df027a8..6d43a44 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ testbench.yaml vendor node_modules .php-cs-fixer.cache - +.phpunit.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index 566bd88..d46d208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to `laravel-cli-scheduler` will be documented in this file. +## 3.0.0 - 2023-09-13 + +- Upgraded to Laravel 10.x +- Upgraded to PHP 8.1 + ## 2.0.0 - 2021-09-07 - Upgraded to Laravel 8.x diff --git a/README.md b/README.md index 6a2ca4b..66e0674 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ Dynamically schedule your [Laravel tasks](https://laravel.com/docs/scheduling) using artisan commands. -[![Latest Version on Packagist](https://img.shields.io/packagist/v/koomai/laravel-cli-scheduler?style=flat-square)](https://packagist.org/packages/koomai/laravel-cli-scheduler) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/koomai/laravel-cli-scheduler.svg?style=flat-square)](https://packagist.org/packages/koomai/laravel-cli-scheduler) [![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/koomai/laravel-cli-scheduler/PHPUnit?label=tests&style=flat-square)](https://github.com/koomai/laravel-cli-scheduler/actions/workflows/run-tests.yml?query=branch%3Amain) [![GitHub Psalm Action Status](https://img.shields.io/github/workflow/status/koomai/laravel-cli-scheduler/Psalm?label=psalm&style=flat-square)](https://github.com/koomai/laravel-cli-scheduler/actions/workflows/psalm.yml?query=branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/koomai/laravel-cli-scheduler/PHP%20CS%20Fixer?label=code%20style&style=flat-square)](https://github.com/koomai/laravel-cli-scheduler/actions/workflows/php-cs-fixer.yml?query=branch%3Amain) -[![Total Downloads](https://img.shields.io/packagist/dt/koomai/laravel-cli-scheduler?style=flat-square)](https://packagist.org/packages/koomai/laravel-cli-scheduler) +[![Total Downloads](https://img.shields.io/packagist/dt/koomai/laravel-cli-scheduler.svg?style=flat-square)](https://packagist.org/packages/koomai/laravel-cli-scheduler) Laravel Scheduler allows you to add, view and remove scheduled tasks in a database via artisan commands. This is particularly useful when you want to schedule tasks without having to redeploy code. diff --git a/composer.json b/composer.json index 4ea698c..1839cf6 100644 --- a/composer.json +++ b/composer.json @@ -16,22 +16,19 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "bensampo/laravel-enum": "^3.4", - "dragonmantank/cron-expression": "^3.1", - "illuminate/console": "^8.0", - "illuminate/contracts": "^8.0", - "illuminate/database": "^8.0" + "php": "^8.1", + "dragonmantank/cron-expression": "^3.3", + "illuminate/console": "^10.0", + "illuminate/contracts": "^10.0", + "illuminate/database": "^10.0" }, "require-dev": { - "brianium/paratest": "^6.2", - "friendsofphp/php-cs-fixer": "^3.1", - "nunomaduro/collision": "^5.3", - "orchestra/testbench": "^6.15", - "phpunit/phpunit": "^9.3", - "psalm/plugin-laravel": "^1.5", - "spatie/laravel-ray": "^1.23", - "vimeo/psalm": "^4.8" + "friendsofphp/php-cs-fixer": "^3.26", + "nunomaduro/collision": "^7.0", + "orchestra/testbench": "^8.10", + "phpunit/phpunit": "^10.1", + "psalm/plugin-laravel": "^2.8", + "vimeo/psalm": "^5.15" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 83604fb..3018930 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,23 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + ./src + + diff --git a/src/Console/Commands/ScheduleAddCommand.php b/src/Console/Commands/ScheduleAddCommand.php index 3b2a1c1..a839516 100644 --- a/src/Console/Commands/ScheduleAddCommand.php +++ b/src/Console/Commands/ScheduleAddCommand.php @@ -99,6 +99,7 @@ private function handleWithoutPrompts(): int */ private function handleWithPrompts(): int { + dump(TaskType::getValues()); $this->type = $this->choice(trans('cli-scheduler::questions.type'), TaskType::getValues()); $this->task = $this->askForTask(); diff --git a/src/Enums/TaskType.php b/src/Enums/TaskType.php index 7d09a48..ab8331a 100644 --- a/src/Enums/TaskType.php +++ b/src/Enums/TaskType.php @@ -2,10 +2,13 @@ namespace Koomai\CliScheduler\Enums; -use BenSampo\Enum\Enum; - -final class TaskType extends Enum +enum TaskType: string { - public const COMMAND = 'Command'; - public const JOB = 'Job'; + case COMMAND = 'Command'; + case JOB = 'Job'; + + public static function getValues(): array + { + return array_column(self::cases(), 'value'); + } } diff --git a/tests/Console/Commands/ScheduleAddCommandWithPromptAndDefaultConfigurationTest.php b/tests/Console/Commands/ScheduleAddCommandWithPromptAndDefaultConfigurationTest.php index 4fe2810..5b555dd 100644 --- a/tests/Console/Commands/ScheduleAddCommandWithPromptAndDefaultConfigurationTest.php +++ b/tests/Console/Commands/ScheduleAddCommandWithPromptAndDefaultConfigurationTest.php @@ -18,7 +18,7 @@ protected function getEnvironmentSetUp($app) public function shouldNotAskForEnvironmentsIfAlreadyDefinedInConfig() { $this->artisan('schedule:add') - ->expectsQuestion(trans('cli-scheduler::questions.type'), TaskType::COMMAND) + ->expectsQuestion(trans('cli-scheduler::questions.type'), TaskType::COMMAND->value) ->expectsQuestion(trans('cli-scheduler::questions.task.artisan'), 'schedule:show') ->expectsQuestion(trans('cli-scheduler::questions.description'), 'Some description') ->expectsQuestion(trans('cli-scheduler::questions.cron'), '* * * * *') diff --git a/tests/Console/Commands/ScheduleAddCommandWithPromptAndNoDefaultConfigurationTest.php b/tests/Console/Commands/ScheduleAddCommandWithPromptAndNoDefaultConfigurationTest.php index 86c6bbe..d4f1f60 100644 --- a/tests/Console/Commands/ScheduleAddCommandWithPromptAndNoDefaultConfigurationTest.php +++ b/tests/Console/Commands/ScheduleAddCommandWithPromptAndNoDefaultConfigurationTest.php @@ -33,7 +33,7 @@ public function should_display_error_and_exit_if_task_type_is_invalid() public function should_prompt_for_all_questions_and_save_artisan_command_task() { $data = [ - 'type' => TaskType::COMMAND, + 'type' => TaskType::COMMAND->value, 'task' => 'inspire --no-interaction', 'description' => 'Some description', 'cron' => '* * * * *', diff --git a/tests/TestCase.php b/tests/TestCase.php index 6f41729..ceee2c3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -22,7 +22,7 @@ protected function defineEnvironment($app) // Setup default database as testing to use sqlite :memory: $app['config']->set('database.default', 'testing'); // Set table name - $app['config']->set('scheduler.table', 'scheduled_tasks'); + $app['config']->set('cli-scheduler.table', 'scheduled_tasks'); } /**