diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 2279fc6..aac0865 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -24,13 +24,34 @@ jobs: - php-version: '8.0' coverage: '--coverage-clover=coverage.clover' storage: doctrine + phpunit-config: 'phpunit-9.xml.dist' - php-version: '8.0' storage: array + phpunit-config: 'phpunit-9.xml.dist' - php-version: '8.1' storage: doctrine + phpunit-config: 'phpunit-9.xml.dist' - php-version: '8.1' storage: array + phpunit-config: 'phpunit-9.xml.dist' + + - php-version: '8.2' + storage: doctrine + - php-version: '8.2' + storage: array + + - php-version: '8.3' + storage: doctrine + - php-version: '8.3' + storage: array + + - php-version: '8.4' + storage: doctrine + composer-flags: --ignore-platform-reqs + - php-version: '8.4' + storage: array + composer-flags: --ignore-platform-reqs steps: - name: Checkout project uses: actions/checkout@v2 @@ -51,7 +72,7 @@ jobs: uses: ramsey/composer-install@v2 with: dependency-versions: ${{ matrix.dependencies }} - composer-options: --prefer-dist --no-suggest + composer-options: --prefer-dist --no-suggest ${{ matrix.composer-flags }} - name: Doctrine if: matrix.storage == 'doctrine' @@ -60,7 +81,7 @@ jobs: tests/app/console doctrine:schema:create - name: Execute test - run: vendor/bin/simple-phpunit -c phpunit.xml.dist ${{ matrix.matrix.coverage }} + run: vendor/bin/phpunit -c ${{ matrix.phpunit-config || 'phpunit.xml.dist' }} ${{ matrix.coverage }} - name: Coverage if: matrix.coverage diff --git a/.gitignore b/.gitignore index 1dff214..695bf7d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ composer.phar /tests/app/logs/ /tests/app/data/ var/ + +.phpunit.cache/ diff --git a/composer.json b/composer.json index c840e74..cbe3d81 100644 --- a/composer.json +++ b/composer.json @@ -10,23 +10,25 @@ } ], "require": { - "php": "^8.0 || ^8.1", + "php": "^8.0", "php-task/php-task": "^2.0", - "symfony/http-kernel": "^5.4 || ^6.0", - "symfony/dependency-injection": "^5.4 || ^6.0", - "symfony/expression-language": "^5.4 || ^6.0", - "symfony/config": "^5.4 || ^6.0", - "symfony/console": "^5.4 || ^6.0", - "symfony/process": "^5.4 || ^6.0", + "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", + "symfony/expression-language": "^5.4 || ^6.0 || ^7.0", + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/process": "^5.4 || ^6.0 || ^7.0", "doctrine/orm": "^2.5.3" }, "require-dev": { - "symfony/framework-bundle": "^5.4 || ^6.0", - "symfony/finder": "^5.4 || ^6.0", - "symfony/yaml": "^5.4 || ^6.0", - "symfony/phpunit-bridge": "^5.4 || ^6.0", + "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0", "doctrine/doctrine-bundle": "^1.5 || ^2.0", - "doctrine/data-fixtures": "^1.3.3" + "doctrine/data-fixtures": "^1.3.3", + "phpunit/phpunit": "^9.6.5 || ^10", + "phpspec/prophecy": "^1.14", + "phpspec/prophecy-phpunit": "^2.0" }, "autoload": { "psr-4": { diff --git a/phpunit-9.xml.dist b/phpunit-9.xml.dist new file mode 100644 index 0000000..0812fdf --- /dev/null +++ b/phpunit-9.xml.dist @@ -0,0 +1,30 @@ + + + + + + + + + + + + + ./tests/ + + + + + + ./ + + ./vendor + ./tests + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7d1a47d..c5d0637 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,15 @@ - + bootstrap="tests/bootstrap.php" + cacheDirectory=".phpunit.cache"> - - - - - - + + + + @@ -20,13 +18,13 @@ - - + + ./ - - ./vendor - ./tests - - - + + + ./vendor + ./tests + + diff --git a/src/Command/DebugTasksCommand.php b/src/Command/DebugTasksCommand.php index 93f8910..4de05e8 100644 --- a/src/Command/DebugTasksCommand.php +++ b/src/Command/DebugTasksCommand.php @@ -42,7 +42,7 @@ public function __construct($name, TaskExecutionRepositoryInterface $taskExecuti /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this->setDescription('Debug tasks') ->setHelp(<<<'EOT' @@ -60,7 +60,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $page = $input->getOption('page'); $pageSize = $input->getOption('page-size'); diff --git a/src/Command/ExecuteCommand.php b/src/Command/ExecuteCommand.php index de1891f..a7ee93d 100644 --- a/src/Command/ExecuteCommand.php +++ b/src/Command/ExecuteCommand.php @@ -65,7 +65,7 @@ public function __construct( /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this->addArgument('uuid', InputArgument::REQUIRED); } @@ -73,7 +73,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $errorOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index 0edc7a1..8defb13 100644 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -48,7 +48,7 @@ public function __construct($name, TaskRunnerInterface $runner, TaskSchedulerInt /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this->setDescription('Run pending tasks') ->setHelp(<<<'EOT' @@ -63,7 +63,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->runner->runTasks(); $this->scheduler->scheduleTasks(); diff --git a/src/Command/RunHandlerCommand.php b/src/Command/RunHandlerCommand.php index b9a36ab..1be42e8 100644 --- a/src/Command/RunHandlerCommand.php +++ b/src/Command/RunHandlerCommand.php @@ -41,7 +41,7 @@ public function __construct($name, TaskHandlerFactoryInterface $handlerFactory) /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this ->setDescription('Run handler') @@ -58,7 +58,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $handlerClass = $input->getArgument('handlerClass'); $workload = $input->getArgument('workload'); diff --git a/src/Command/ScheduleSystemTasksCommand.php b/src/Command/ScheduleSystemTasksCommand.php index fda9c80..f9e00ef 100644 --- a/src/Command/ScheduleSystemTasksCommand.php +++ b/src/Command/ScheduleSystemTasksCommand.php @@ -63,7 +63,7 @@ public function __construct( /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this->setDescription('Schedule system-tasks')->setHelp( <<<'EOT' @@ -79,7 +79,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln(sprintf('Schedule %s system-tasks:', count($this->systemTasks))); $output->writeln(''); diff --git a/src/Command/ScheduleTaskCommand.php b/src/Command/ScheduleTaskCommand.php index f6931c5..16a2fc7 100644 --- a/src/Command/ScheduleTaskCommand.php +++ b/src/Command/ScheduleTaskCommand.php @@ -42,7 +42,7 @@ public function __construct($name, TaskSchedulerInterface $runner) /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this ->setDescription('Schedule task') @@ -66,7 +66,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $handlerClass = $input->getArgument('handlerClass'); $workload = $input->getArgument('workload'); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 5d521c4..b1df39b 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -36,7 +36,7 @@ public function __construct(array $lockingStorageAliases) /** * {@inheritdoc} */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('task'); diff --git a/tests/Functional/BaseCommandTestCase.php b/tests/Functional/BaseCommandTestCase.php index 51dfcdb..344de77 100644 --- a/tests/Functional/BaseCommandTestCase.php +++ b/tests/Functional/BaseCommandTestCase.php @@ -69,7 +69,7 @@ abstract class BaseCommandTestCase extends KernelTestCase */ protected $commandTester; - public function setUp() + protected function setUp(): void { self::bootKernel(); diff --git a/tests/Functional/BaseDatabaseTestCase.php b/tests/Functional/BaseDatabaseTestCase.php index 92cffd3..4380eb6 100644 --- a/tests/Functional/BaseDatabaseTestCase.php +++ b/tests/Functional/BaseDatabaseTestCase.php @@ -22,7 +22,7 @@ abstract class BaseDatabaseTestCase extends KernelTestCase /** * {@inheritdoc} */ - public function setUp() + protected function setUp(): void { self::bootKernel(); diff --git a/tests/Functional/Command/ScheduleSystemTasksCommandTest.php b/tests/Functional/Command/ScheduleSystemTasksCommandTest.php index ff80556..1cf217a 100644 --- a/tests/Functional/Command/ScheduleSystemTasksCommandTest.php +++ b/tests/Functional/Command/ScheduleSystemTasksCommandTest.php @@ -7,11 +7,11 @@ class ScheduleSystemTasksCommandTest extends BaseCommandTestCase { - public function setUp() + protected function setUp(): void { self::bootKernel(); if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) { - return $this->markTestSkipped('This testcase will only be called for doctrine storage.'); + $this->markTestSkipped('This testcase will only be called for doctrine storage.'); } parent::setUp(); diff --git a/tests/Functional/Entity/TaskExecutionRepositoryTest.php b/tests/Functional/Entity/TaskExecutionRepositoryTest.php index 1716f3a..6ecc982 100644 --- a/tests/Functional/Entity/TaskExecutionRepositoryTest.php +++ b/tests/Functional/Entity/TaskExecutionRepositoryTest.php @@ -25,7 +25,7 @@ class TaskExecutionRepositoryTest extends BaseDatabaseTestCase */ protected $taskRepository; - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/Functional/Entity/TaskRepositoryTest.php b/tests/Functional/Entity/TaskRepositoryTest.php index b02ed0f..a8e2e59 100644 --- a/tests/Functional/Entity/TaskRepositoryTest.php +++ b/tests/Functional/Entity/TaskRepositoryTest.php @@ -12,7 +12,7 @@ class TaskRepositoryTest extends BaseDatabaseTestCase */ protected $taskRepository; - public function setUp() + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ public function setUp() public function testFindBySystemKey() { if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) { - return $this->markTestSkipped('This testcase will only be called for doctrine storage.'); + $this->markTestSkipped('This testcase will only be called for doctrine storage.'); } $task = $this->createTask(); @@ -37,7 +37,7 @@ public function testFindBySystemKey() public function testFindBySystemKeyNotFound() { if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) { - return $this->markTestSkipped('This testcase will only be called for doctrine storage.'); + $this->markTestSkipped('This testcase will only be called for doctrine storage.'); } $task = $this->createTask(); @@ -49,7 +49,7 @@ public function testFindBySystemKeyNotFound() public function testFindSystemTasks() { if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) { - return $this->markTestSkipped('This testcase will only be called for doctrine storage.'); + $this->markTestSkipped('This testcase will only be called for doctrine storage.'); } $task1 = $this->createTask(); diff --git a/tests/Functional/Handler/TaskHandlerFactoryTest.php b/tests/Functional/Handler/TaskHandlerFactoryTest.php index 22a6e96..67c9919 100644 --- a/tests/Functional/Handler/TaskHandlerFactoryTest.php +++ b/tests/Functional/Handler/TaskHandlerFactoryTest.php @@ -26,7 +26,7 @@ class TaskHandlerFactoryTest extends KernelTestCase */ private $taskHandlerFactory; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/Unit/Builder/TaskBuilderFactoryTest.php b/tests/Unit/Builder/TaskBuilderFactoryTest.php index 7e96346..1c57621 100644 --- a/tests/Unit/Builder/TaskBuilderFactoryTest.php +++ b/tests/Unit/Builder/TaskBuilderFactoryTest.php @@ -3,6 +3,7 @@ namespace Unit\Builder; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Task\Scheduler\TaskSchedulerInterface; use Task\TaskBundle\Builder\TaskBuilder; use Task\TaskBundle\Builder\TaskBuilderFactory; @@ -10,6 +11,8 @@ class TaskBuilderFactoryTest extends TestCase { + use ProphecyTrait; + public function testCreate() { $task = $this->prophesize(TaskInterface::class); diff --git a/tests/Unit/Builder/TaskBuilderTest.php b/tests/Unit/Builder/TaskBuilderTest.php index 64e421b..019ff47 100644 --- a/tests/Unit/Builder/TaskBuilderTest.php +++ b/tests/Unit/Builder/TaskBuilderTest.php @@ -3,6 +3,7 @@ namespace Task\TaskBundle\Unit\Builder; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Task\Scheduler\TaskSchedulerInterface; use Task\TaskBundle\Builder\NotSupportedMethodException; use Task\TaskBundle\Builder\TaskBuilder; @@ -11,6 +12,8 @@ class TaskBuilderTest extends TestCase { + use ProphecyTrait; + public function testSetSystemKey() { $task = $this->prophesize(Task::class); diff --git a/tests/Unit/Command/ScheduleSystemTasksCommandTest.php b/tests/Unit/Command/ScheduleSystemTasksCommandTest.php index 505abc1..c8eb9b0 100644 --- a/tests/Unit/Command/ScheduleSystemTasksCommandTest.php +++ b/tests/Unit/Command/ScheduleSystemTasksCommandTest.php @@ -5,6 +5,7 @@ use Cron\CronExpression; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\OutputInterface; use Task\Execution\TaskExecutionInterface; @@ -19,6 +20,8 @@ class ScheduleSystemTasksCommandTest extends TestCase { + use ProphecyTrait; + /** * @var TaskSchedulerInterface */ @@ -34,7 +37,7 @@ class ScheduleSystemTasksCommandTest extends TestCase */ private $taskExecutionRepository; - protected function setUp() + protected function setUp(): void { $this->scheduler = $this->prophesize(TaskSchedulerInterface::class); $this->taskRepository = $this->prophesize(TaskRepository::class); diff --git a/tests/Unit/DependencyInjection/HandlerCompilerPassTest.php b/tests/Unit/DependencyInjection/HandlerCompilerPassTest.php index d4c2677..df5587f 100644 --- a/tests/Unit/DependencyInjection/HandlerCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/HandlerCompilerPassTest.php @@ -12,6 +12,7 @@ namespace Task\TaskBundle\Unit\DependencyInjection; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; @@ -22,6 +23,8 @@ */ class HandlerCompilerPassTest extends TestCase { + use ProphecyTrait; + public function testProcess() { $container = $this->prophesize(ContainerBuilder::class); diff --git a/tests/Unit/EventListener/RunListenerTest.php b/tests/Unit/EventListener/RunListenerTest.php index 68b23d1..e5157aa 100644 --- a/tests/Unit/EventListener/RunListenerTest.php +++ b/tests/Unit/EventListener/RunListenerTest.php @@ -12,6 +12,7 @@ namespace Task\TaskBundle\Tests\Unit\EventListener; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\EventDispatcher\Event as LegacyEvent; use Symfony\Contracts\EventDispatcher\Event; use Task\Runner\TaskRunnerInterface; @@ -22,6 +23,8 @@ */ class RunListenerTest extends TestCase { + use ProphecyTrait; + public function testRun() { if (\class_exists(LegacyEvent::class)) { diff --git a/tests/Unit/EventListener/TaskExecutionListenerTest.php b/tests/Unit/EventListener/TaskExecutionListenerTest.php index 3f371e8..d542af3 100644 --- a/tests/Unit/EventListener/TaskExecutionListenerTest.php +++ b/tests/Unit/EventListener/TaskExecutionListenerTest.php @@ -13,6 +13,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Task\Event\TaskExecutionEvent; use Task\TaskBundle\EventListener\DoctrineTaskExecutionListener; @@ -21,6 +22,8 @@ */ class TaskExecutionListenerTest extends TestCase { + use ProphecyTrait; + public function testClearEntityManagerAfterTask() { $entityManager = $this->prophesize(EntityManagerInterface::class); diff --git a/tests/Unit/Executor/SeparateProcessExecutorTest.php b/tests/Unit/Executor/SeparateProcessExecutorTest.php index ec9b0a0..7072ed9 100644 --- a/tests/Unit/Executor/SeparateProcessExecutorTest.php +++ b/tests/Unit/Executor/SeparateProcessExecutorTest.php @@ -12,6 +12,7 @@ namespace Task\TaskBundle\Tests\Unit\Executor; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Process\Process; use Task\Execution\TaskExecutionInterface; use Task\Executor\FailedException; @@ -25,6 +26,8 @@ class SeparateProcessExecutorTest extends TestCase { + use ProphecyTrait; + /** * @var TaskHandlerFactoryInterface */ @@ -65,7 +68,7 @@ class SeparateProcessExecutorTest extends TestCase */ private $process; - protected function setUp() + protected function setUp(): void { $this->handlerFactory = $this->prophesize(TaskHandlerFactoryInterface::class); $this->executionRepository = $this->prophesize(TaskExecutionRepositoryInterface::class); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 388c0e9..37f15b1 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,6 +11,8 @@ require __DIR__ . '/app/TestKernel.php'; -AnnotationRegistry::registerLoader([$loader, 'loadClass']); +if (\class_exists(AnnotationRegistry::class)) { + AnnotationRegistry::registerLoader([$loader, 'loadClass']); +} return $loader;