Skip to content

Commit

Permalink
Add support for Symfony 7 (#55)
Browse files Browse the repository at this point in the history
* Add support for Symfony 7

* Upgrade PHPUnit

* Run annotation registry only when available

* Add return types to PHPUnit setup

* Add missing prophecy trait

* Remove PHPUnit 11 support

* Reformat phpunit.xml.dist file
  • Loading branch information
alexander-schranz authored Jul 16, 2024
1 parent aad451d commit b9d8943
Show file tree
Hide file tree
Showing 26 changed files with 133 additions and 57 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ composer.phar
/tests/app/logs/
/tests/app/data/
var/

.phpunit.cache/
26 changes: 14 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
30 changes: 30 additions & 0 deletions phpunit-9.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php">
<php>
<ini name="error_reporting" value="-1" />
<ini name="date.timezone" value="UTC" />
<server name="KERNEL_DIR" value="tests/app" />
<server name="KERNEL_CLASS" value="TestKernel" />
</php>

<testsuites>
<testsuite name="php-task Library Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
32 changes: 15 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php">
bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="tests/app" />
<server name="KERNEL_CLASS" value="TestKernel" />
<env name="SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT" value="1"/>
<env name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<ini name="error_reporting" value="-1"/>
<ini name="date.timezone" value="UTC"/>
<server name="KERNEL_DIR" value="tests/app"/>
<server name="KERNEL_CLASS" value="TestKernel"/>
</php>

<testsuites>
Expand All @@ -20,13 +18,13 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<source>
<include>
<directory>./</directory>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/Command/DebugTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($name, TaskExecutionRepositoryInterface $taskExecuti
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this->setDescription('Debug tasks')
->setHelp(<<<'EOT'
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public function __construct(
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this->addArgument('uuid', InputArgument::REQUIRED);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$errorOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;

Expand Down
4 changes: 2 additions & 2 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Command/RunHandlerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct($name, TaskHandlerFactoryInterface $handlerFactory)
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Run handler')
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ScheduleSystemTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this->setDescription('Schedule system-tasks')->setHelp(
<<<'EOT'
Expand All @@ -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('');
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ScheduleTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($name, TaskSchedulerInterface $runner)
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Schedule task')
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(array $lockingStorageAliases)
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('task');

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/BaseCommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class BaseCommandTestCase extends KernelTestCase
*/
protected $commandTester;

public function setUp()
protected function setUp(): void
{
self::bootKernel();

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/BaseDatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class BaseDatabaseTestCase extends KernelTestCase
/**
* {@inheritdoc}
*/
public function setUp()
protected function setUp(): void
{
self::bootKernel();

Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Command/ScheduleSystemTasksCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Entity/TaskExecutionRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TaskExecutionRepositoryTest extends BaseDatabaseTestCase
*/
protected $taskRepository;

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
8 changes: 4 additions & 4 deletions tests/Functional/Entity/TaskRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TaskRepositoryTest extends BaseDatabaseTestCase
*/
protected $taskRepository;

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Handler/TaskHandlerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TaskHandlerFactoryTest extends KernelTestCase
*/
private $taskHandlerFactory;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Builder/TaskBuilderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
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;
use Task\TaskInterface;

class TaskBuilderFactoryTest extends TestCase
{
use ProphecyTrait;

public function testCreate()
{
$task = $this->prophesize(TaskInterface::class);
Expand Down
Loading

0 comments on commit b9d8943

Please sign in to comment.