Skip to content

Commit

Permalink
Merge pull request #1 from koomai/feature/v3
Browse files Browse the repository at this point in the history
Feature/v3
  • Loading branch information
koomai committed Sep 13, 2023
2 parents 4b1e0c0 + 32773dd commit 48b6a66
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ testbench.yaml
vendor
node_modules
.php-cs-fixer.cache

.phpunit.cache
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
25 changes: 11 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
58 changes: 21 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Cli Scheduler Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Cli Scheduler Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
1 change: 1 addition & 0 deletions src/Console/Commands/ScheduleAddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 8 additions & 5 deletions src/Enums/TaskType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'), '* * * * *')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '* * * * *',
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down

0 comments on commit 48b6a66

Please sign in to comment.