Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2']
php-versions: ['8.2', '8.3']
name: Test with PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
fail-fast: false
matrix:
php-version:
- '8.1'
- '8.2'
- '8.3'

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: intl
coverage: none

Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"blitz-php/parametres": "^1.0"
"blitz-php/parametres": "^1.4.0-rc"
},
"require-dev": {
"blitz-php/coding-standard": "^1.4",
"blitz-php/framework": "^0.12",
"blitz-php/coding-standard": "^1.6",
"blitz-php/framework": "^1.0.13-rc",
"blitz-php/http-client": "^0.0.2",
"blitz-php/queue": "^0.2.0",
"kahlan/kahlan": "^6.0",
"phpstan/phpstan": "^2.1"
"kahlan/kahlan": "^6.1",
"phpstan/phpstan": "^2.3"
},
"autoload": {
"psr-4": {
Expand Down
54 changes: 48 additions & 6 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,60 @@
'count' => 1,
'path' => __DIR__ . '/src/Commands/Run.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method startOfMinute\\(\\) on BlitzPHP\\\\Utilities\\\\Date\\|string\\.$#',
'identifier' => 'method.nonObject',
'count' => 2,
'path' => __DIR__ . '/src/Commands/Work.php',
];
$ignoreErrors[] = [
'message' => '#^While loop condition is always true\\.$#',
'identifier' => 'while.alwaysTrue',
'count' => 1,
'path' => __DIR__ . '/src/Commands/Work.php',
];
$ignoreErrors[] = [
'message' => '#^Access to constant class on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#',
'identifier' => 'class.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^Access to property \\$driver on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#',
'identifier' => 'class.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^Call to method execute\\(\\) on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#',
'identifier' => 'class.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^Call to method queue\\(\\) on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#',
'identifier' => 'class.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^PHPDoc tag @var for variable \\$job contains unknown class BlitzPHP\\\\Queue\\\\Job\\.$#',
'identifier' => 'class.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<container\\>, string given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<queue\\>, string given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\$job of method BlitzPHP\\\\Tasks\\\\Scheduler\\:\\:job\\(\\) has invalid type BlitzPHP\\\\Queue\\\\Job\\.$#',
'identifier' => 'class.notFound',
'count' => 2,
'path' => __DIR__ . '/src/Scheduler.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<container\\>, string given\\.$#',
'identifier' => 'argument.type',
Expand Down
5 changes: 1 addition & 4 deletions spec/Command.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@
});

it('Publisher', function () {
config()->ghost('publisher')->set('publisher.restrictions', [ROOTPATH => '*']);

$path = CONFIG_PATH . 'tasks.php';

expect(file_exists($path))->toBeFalsy();

// conserver les fichiers originaux car a la fin, on suppimera tous les fichiers publiés
$original_files = array_map(fn ($f) => $f->getRelativePathname(), service('fs')->files(CONFIG_PATH));

command('publish');
// command('publish --namespace=BlitzPHP\\\\Tasks');
command('config:publish tasks');

expect(file_exists($path))->toBeTruthy();

Expand Down
2 changes: 1 addition & 1 deletion spec/CronExpression.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use BlitzPHP\Tasks\CronExpression;
use BlitzPHP\Tasks\Exceptions\TasksException;
use BlitzPHP\Utilities\Date;
use BlitzPHP\Utilities\DateTime\Date;

use function Kahlan\expect;

Expand Down
2 changes: 1 addition & 1 deletion spec/FrequenciesTrait.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

use BlitzPHP\Tasks\FrequenciesTrait;
use BlitzPHP\Utilities\Date;
use BlitzPHP\Utilities\DateTime\Date;

use function Kahlan\expect;

Expand Down
7 changes: 4 additions & 3 deletions spec/Task.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use BlitzPHP\Spec\ReflectionHelper;
use BlitzPHP\Tasks\Exceptions\TasksException;
use BlitzPHP\Tasks\Task;
use BlitzPHP\Utilities\Date;
use BlitzPHP\Utilities\DateTime\Date;
use BlitzPHP\Utilities\Helpers;

use function Kahlan\expect;
Expand Down Expand Up @@ -134,8 +134,9 @@
]]);

// Doit renvoyer l'heure actuelle
expect($task->lastRun())->toBeAnInstanceOf(Date::class); // @phpstan-ignore-line
expect($task->lastRun()->format('Y-m-d H:i:s'))->toBe($date);
$lastRun = $task->lastRun();
expect($lastRun)->toBeAnInstanceOf(Date::class); // @phpstan-ignore-line
expect($lastRun->format('Y-m-d H:i:s'))->toBe($date);
});

it('Execute une tache unique', function () {
Expand Down
2 changes: 1 addition & 1 deletion spec/TaskLog.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use BlitzPHP\Tasks\Task;
use BlitzPHP\Tasks\TaskLog;
use BlitzPHP\Utilities\Date;
use BlitzPHP\Utilities\DateTime\Date;

use function Kahlan\expect;

Expand Down
8 changes: 4 additions & 4 deletions spec/_support/Commands/TasksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/
final class TasksTest extends Command
{
protected $group = 'Testing';
protected $name = 'tasks:test';
protected $description = 'Tests Tasks';
protected string $group = 'Testing';
protected string $name = 'tasks:test';
protected string $description = 'Tests Tasks';

public function execute(array $params)
public function handle()
{
$this->write('La commande peut produire du texte.');
}
Expand Down
2 changes: 1 addition & 1 deletion spec/_support/Config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
return [
'base_url' => 'http://localhost',
'environment' => 'testing',
'language' => 'en',
'locale' => 'en',
'show_debugbar' => false,
];
40 changes: 29 additions & 11 deletions spec/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,43 @@
* the LICENSE file that was distributed with this source code.
*/

use BlitzPHP\Tasks\Config\Services;
use BlitzPHP\Initializer\Boot;

error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

// S'assure qu'il reconnaît que nous testons.
$_SERVER['ENVIRONMENT'] = 'testing';
define('ENVIRONMENT', 'testing');
define('BLITZ_DEBUG', true);

// Souvent, ces constantes sont prédéfinies, mais interroger la structure actuelle du répertoire comme un repli
defined('HOME_PATH') || define('HOME_PATH', realpath(rtrim(getcwd(), '\\/ ')) . DIRECTORY_SEPARATOR);
defined('VENDOR_PATH') || define('VENDOR_PATH', realpath(HOME_PATH . 'vendor') . DIRECTORY_SEPARATOR);

define('APP_NAMESPACE', 'App');
define('APP_PATH', __DIR__ . '/_support/');
define('WEBROOT', APP_PATH);
define('STORAGE_PATH', APP_PATH);
if (! is_file($autoload_file = realpath(VENDOR_PATH . 'autoload.php')) ?: '') {
echo 'Votre fichier autoload de Composer ne semble pas être défini correctement. ';
echo 'Veuillez ouvrir le fichier suivant et pour corriger: "' . __FILE__ . '"';

exit(3); // EXIT_CONFIG
}

define('SYST_PATH', VENDOR_PATH . 'blitz-php/framework/src/');
define('APPLICATION_PATH', __DIR__ . '/_support/');
define('TEST_PATH', __DIR__ . '/');
define('WEBROOT', APPLICATION_PATH);

require_once $autoload_file;
require_once SYST_PATH . 'Initializer' . DIRECTORY_SEPARATOR . 'Boot.php';

require_once SYST_PATH . 'Constants/constants.php';
require_once SYST_PATH . 'Helpers/common.php';
require_once SYST_PATH . 'Helpers/path.php';
$paths = ['app' => APPLICATION_PATH, 'storage' => APPLICATION_PATH, 'test' => TEST_PATH, 'composer' => VENDOR_PATH];
Boot::test($paths, __FILE__);

Services::autoloader()->initialize()->register();
Services::container()->initialize();
helper('path');

config()->load('parametres', VENDOR_PATH . 'blitz-php/parametres/src/Config/parametres.php');
config()->set('parametres.file.path', storage_path('.parametres.json'));
config()->set('parametres.json.file', storage_path('.parametres.json'));
config()->set('parametres.handlers', ['json']);
config()->load('tasks', __DIR__ . '/../src/Config/tasks.php');
config()->ghost('cache', ['handler' => 'file']);
6 changes: 3 additions & 3 deletions src/Commands/Disable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ class Disable extends TaskCommand
/**
* {@inheritDoc}
*/
protected $name = 'tasks:disable';
protected string $name = 'tasks:disable';

/**
* {@inheritDoc}
*/
protected $description = 'Désactive l\'exécuteur de tâches.';
protected string $description = 'Désactive l\'exécuteur de tâches.';

/**
* {@inheritDoc}
*
* @return void
*/
public function execute(array $params)
public function handle()
{
parametre('tasks.enabled', false);

Expand Down
6 changes: 3 additions & 3 deletions src/Commands/Enable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ class Enable extends TaskCommand
/**
* {@inheritDoc}
*/
protected $name = 'tasks:enable';
protected string $name = 'tasks:enable';

/**
* {@inheritDoc}
*/
protected $description = 'Active l\'exécuteur de tâches.';
protected string $description = 'Active l\'exécuteur de tâches.';

/**
* {@inheritDoc}
*
* @return void
*/
public function execute(array $params)
public function handle()
{
parametre('tasks.enabled', true);

Expand Down
8 changes: 4 additions & 4 deletions src/Commands/Lister.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use BlitzPHP\Tasks\CronExpression;
use BlitzPHP\Tasks\Scheduler;
use BlitzPHP\Utilities\Date;
use BlitzPHP\Utilities\DateTime\Date;

/**
* Répertorie les tâches actuellement planifiées.
Expand All @@ -25,19 +25,19 @@ class Lister extends TaskCommand
/**
* {@inheritDoc}
*/
protected $name = 'tasks:list';
protected string $name = 'tasks:list';

/**
* {@inheritDoc}
*/
protected $description = 'Répertorie les tâches actuellement configurées pour être exécutées.';
protected string $description = 'Répertorie les tâches actuellement configurées pour être exécutées.';

/**
* {@inheritDoc}
*
* @return void
*/
public function execute(array $params)
public function handle()
{
if (parametre('tasks.enabled') === false) {
$this->writer->error('WARNING: L\'exécution de la tâche est actuellement désactivée.', true);
Expand Down
10 changes: 5 additions & 5 deletions src/Commands/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ class Run extends TaskCommand
/**
* {@inheritDoc}
*/
protected $name = 'tasks:run';
protected string $name = 'tasks:run';

/**
* {@inheritDoc}
*/
protected $options = [
'--task' => 'Exécuter une tâche spécifique par son alias.',
protected array $options = [
'--task' => ['Exécuter une tâche spécifique par son alias.'],
];

/**
* {@inheritDoc}
*/
protected $description = 'Exécute des tâches en fonction de la planification, doit être configuré comme une tâche cron pour s\'exécuter toutes les minutes.';
protected string $description = 'Exécute des tâches en fonction de la planification, doit être configuré comme une tâche cron pour s\'exécuter toutes les minutes.';

/**
* {@inheritDoc}
*
* @return int
*/
public function execute(array $params)
public function handle()
{
if (parametre('tasks.enabled') === false) {
$this->writer->error('WARNING: L\'exécution de la tâche est actuellement désactivée.', true);
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/TaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class TaskCommand extends Command
/**
* {@inheritDoc}
*/
protected $group = 'Tasks';
protected string $group = 'Tasks';

/**
* emplacement pour sauvegarder.
Expand Down
Loading
Loading