Skip to content

Commit b9d8943

Browse files
Add support for Symfony 7 (#55)
* 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
1 parent aad451d commit b9d8943

26 files changed

+133
-57
lines changed

.github/workflows/test-application.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ jobs:
2424
- php-version: '8.0'
2525
coverage: '--coverage-clover=coverage.clover'
2626
storage: doctrine
27+
phpunit-config: 'phpunit-9.xml.dist'
2728
- php-version: '8.0'
2829
storage: array
30+
phpunit-config: 'phpunit-9.xml.dist'
2931

3032
- php-version: '8.1'
3133
storage: doctrine
34+
phpunit-config: 'phpunit-9.xml.dist'
3235
- php-version: '8.1'
3336
storage: array
37+
phpunit-config: 'phpunit-9.xml.dist'
38+
39+
- php-version: '8.2'
40+
storage: doctrine
41+
- php-version: '8.2'
42+
storage: array
43+
44+
- php-version: '8.3'
45+
storage: doctrine
46+
- php-version: '8.3'
47+
storage: array
48+
49+
- php-version: '8.4'
50+
storage: doctrine
51+
composer-flags: --ignore-platform-reqs
52+
- php-version: '8.4'
53+
storage: array
54+
composer-flags: --ignore-platform-reqs
3455
steps:
3556
- name: Checkout project
3657
uses: actions/checkout@v2
@@ -51,7 +72,7 @@ jobs:
5172
uses: ramsey/composer-install@v2
5273
with:
5374
dependency-versions: ${{ matrix.dependencies }}
54-
composer-options: --prefer-dist --no-suggest
75+
composer-options: --prefer-dist --no-suggest ${{ matrix.composer-flags }}
5576

5677
- name: Doctrine
5778
if: matrix.storage == 'doctrine'
@@ -60,7 +81,7 @@ jobs:
6081
tests/app/console doctrine:schema:create
6182
6283
- name: Execute test
63-
run: vendor/bin/simple-phpunit -c phpunit.xml.dist ${{ matrix.matrix.coverage }}
84+
run: vendor/bin/phpunit -c ${{ matrix.phpunit-config || 'phpunit.xml.dist' }} ${{ matrix.coverage }}
6485

6586
- name: Coverage
6687
if: matrix.coverage

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ composer.phar
99
/tests/app/logs/
1010
/tests/app/data/
1111
var/
12+
13+
.phpunit.cache/

composer.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,25 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.0 || ^8.1",
13+
"php": "^8.0",
1414
"php-task/php-task": "^2.0",
15-
"symfony/http-kernel": "^5.4 || ^6.0",
16-
"symfony/dependency-injection": "^5.4 || ^6.0",
17-
"symfony/expression-language": "^5.4 || ^6.0",
18-
"symfony/config": "^5.4 || ^6.0",
19-
"symfony/console": "^5.4 || ^6.0",
20-
"symfony/process": "^5.4 || ^6.0",
15+
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
16+
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
17+
"symfony/expression-language": "^5.4 || ^6.0 || ^7.0",
18+
"symfony/config": "^5.4 || ^6.0 || ^7.0",
19+
"symfony/console": "^5.4 || ^6.0 || ^7.0",
20+
"symfony/process": "^5.4 || ^6.0 || ^7.0",
2121
"doctrine/orm": "^2.5.3"
2222
},
2323
"require-dev": {
24-
"symfony/framework-bundle": "^5.4 || ^6.0",
25-
"symfony/finder": "^5.4 || ^6.0",
26-
"symfony/yaml": "^5.4 || ^6.0",
27-
"symfony/phpunit-bridge": "^5.4 || ^6.0",
24+
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
25+
"symfony/finder": "^5.4 || ^6.0 || ^7.0",
26+
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
2827
"doctrine/doctrine-bundle": "^1.5 || ^2.0",
29-
"doctrine/data-fixtures": "^1.3.3"
28+
"doctrine/data-fixtures": "^1.3.3",
29+
"phpunit/phpunit": "^9.6.5 || ^10",
30+
"phpspec/prophecy": "^1.14",
31+
"phpspec/prophecy-phpunit": "^2.0"
3032
},
3133
"autoload": {
3234
"psr-4": {

phpunit-9.xml.dist

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="tests/bootstrap.php">
8+
<php>
9+
<ini name="error_reporting" value="-1" />
10+
<ini name="date.timezone" value="UTC" />
11+
<server name="KERNEL_DIR" value="tests/app" />
12+
<server name="KERNEL_CLASS" value="TestKernel" />
13+
</php>
14+
15+
<testsuites>
16+
<testsuite name="php-task Library Test Suite">
17+
<directory>./tests/</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<filter>
22+
<whitelist>
23+
<directory>./</directory>
24+
<exclude>
25+
<directory>./vendor</directory>
26+
<directory>./tests</directory>
27+
</exclude>
28+
</whitelist>
29+
</filter>
30+
</phpunit>

phpunit.xml.dist

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
54
backupGlobals="false"
65
colors="true"
7-
bootstrap="tests/bootstrap.php">
6+
bootstrap="tests/bootstrap.php"
7+
cacheDirectory=".phpunit.cache">
88
<php>
9-
<ini name="error_reporting" value="-1" />
10-
<server name="KERNEL_DIR" value="tests/app" />
11-
<server name="KERNEL_CLASS" value="TestKernel" />
12-
<env name="SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT" value="1"/>
13-
<env name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>
14-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
9+
<ini name="error_reporting" value="-1"/>
10+
<ini name="date.timezone" value="UTC"/>
11+
<server name="KERNEL_DIR" value="tests/app"/>
12+
<server name="KERNEL_CLASS" value="TestKernel"/>
1513
</php>
1614

1715
<testsuites>
@@ -20,13 +18,13 @@
2018
</testsuite>
2119
</testsuites>
2220

23-
<filter>
24-
<whitelist>
21+
<source>
22+
<include>
2523
<directory>./</directory>
26-
<exclude>
27-
<directory>./vendor</directory>
28-
<directory>./tests</directory>
29-
</exclude>
30-
</whitelist>
31-
</filter>
24+
</include>
25+
<exclude>
26+
<directory>./vendor</directory>
27+
<directory>./tests</directory>
28+
</exclude>
29+
</source>
3230
</phpunit>

src/Command/DebugTasksCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($name, TaskExecutionRepositoryInterface $taskExecuti
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
protected function configure()
45+
protected function configure(): void
4646
{
4747
$this->setDescription('Debug tasks')
4848
->setHelp(<<<'EOT'
@@ -60,7 +60,7 @@ protected function configure()
6060
/**
6161
* {@inheritdoc}
6262
*/
63-
protected function execute(InputInterface $input, OutputInterface $output)
63+
protected function execute(InputInterface $input, OutputInterface $output): int
6464
{
6565
$page = $input->getOption('page');
6666
$pageSize = $input->getOption('page-size');

src/Command/ExecuteCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ public function __construct(
6565
/**
6666
* {@inheritdoc}
6767
*/
68-
protected function configure()
68+
protected function configure(): void
6969
{
7070
$this->addArgument('uuid', InputArgument::REQUIRED);
7171
}
7272

7373
/**
7474
* {@inheritdoc}
7575
*/
76-
protected function execute(InputInterface $input, OutputInterface $output)
76+
protected function execute(InputInterface $input, OutputInterface $output): int
7777
{
7878
$errorOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
7979

src/Command/RunCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct($name, TaskRunnerInterface $runner, TaskSchedulerInt
4848
/**
4949
* {@inheritdoc}
5050
*/
51-
protected function configure()
51+
protected function configure(): void
5252
{
5353
$this->setDescription('Run pending tasks')
5454
->setHelp(<<<'EOT'
@@ -63,7 +63,7 @@ protected function configure()
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
protected function execute(InputInterface $input, OutputInterface $output)
66+
protected function execute(InputInterface $input, OutputInterface $output): int
6767
{
6868
$this->runner->runTasks();
6969
$this->scheduler->scheduleTasks();

src/Command/RunHandlerCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct($name, TaskHandlerFactoryInterface $handlerFactory)
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
protected function configure()
44+
protected function configure(): void
4545
{
4646
$this
4747
->setDescription('Run handler')
@@ -58,7 +58,7 @@ protected function configure()
5858
/**
5959
* {@inheritdoc}
6060
*/
61-
protected function execute(InputInterface $input, OutputInterface $output)
61+
protected function execute(InputInterface $input, OutputInterface $output): int
6262
{
6363
$handlerClass = $input->getArgument('handlerClass');
6464
$workload = $input->getArgument('workload');

src/Command/ScheduleSystemTasksCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct(
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
protected function configure()
66+
protected function configure(): void
6767
{
6868
$this->setDescription('Schedule system-tasks')->setHelp(
6969
<<<'EOT'
@@ -79,7 +79,7 @@ protected function configure()
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
protected function execute(InputInterface $input, OutputInterface $output)
82+
protected function execute(InputInterface $input, OutputInterface $output): int
8383
{
8484
$output->writeln(sprintf('Schedule %s system-tasks:', count($this->systemTasks)));
8585
$output->writeln('');

src/Command/ScheduleTaskCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($name, TaskSchedulerInterface $runner)
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
protected function configure()
45+
protected function configure(): void
4646
{
4747
$this
4848
->setDescription('Schedule task')
@@ -66,7 +66,7 @@ protected function configure()
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
protected function execute(InputInterface $input, OutputInterface $output)
69+
protected function execute(InputInterface $input, OutputInterface $output): int
7070
{
7171
$handlerClass = $input->getArgument('handlerClass');
7272
$workload = $input->getArgument('workload');

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(array $lockingStorageAliases)
3636
/**
3737
* {@inheritdoc}
3838
*/
39-
public function getConfigTreeBuilder()
39+
public function getConfigTreeBuilder(): TreeBuilder
4040
{
4141
$treeBuilder = new TreeBuilder('task');
4242

tests/Functional/BaseCommandTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ abstract class BaseCommandTestCase extends KernelTestCase
6969
*/
7070
protected $commandTester;
7171

72-
public function setUp()
72+
protected function setUp(): void
7373
{
7474
self::bootKernel();
7575

tests/Functional/BaseDatabaseTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class BaseDatabaseTestCase extends KernelTestCase
2222
/**
2323
* {@inheritdoc}
2424
*/
25-
public function setUp()
25+
protected function setUp(): void
2626
{
2727
self::bootKernel();
2828

tests/Functional/Command/ScheduleSystemTasksCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
class ScheduleSystemTasksCommandTest extends BaseCommandTestCase
99
{
10-
public function setUp()
10+
protected function setUp(): void
1111
{
1212
self::bootKernel();
1313
if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) {
14-
return $this->markTestSkipped('This testcase will only be called for doctrine storage.');
14+
$this->markTestSkipped('This testcase will only be called for doctrine storage.');
1515
}
1616

1717
parent::setUp();

tests/Functional/Entity/TaskExecutionRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TaskExecutionRepositoryTest extends BaseDatabaseTestCase
2525
*/
2626
protected $taskRepository;
2727

28-
public function setUp()
28+
protected function setUp(): void
2929
{
3030
parent::setUp();
3131

tests/Functional/Entity/TaskRepositoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TaskRepositoryTest extends BaseDatabaseTestCase
1212
*/
1313
protected $taskRepository;
1414

15-
public function setUp()
15+
protected function setUp(): void
1616
{
1717
parent::setUp();
1818

@@ -22,7 +22,7 @@ public function setUp()
2222
public function testFindBySystemKey()
2323
{
2424
if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) {
25-
return $this->markTestSkipped('This testcase will only be called for doctrine storage.');
25+
$this->markTestSkipped('This testcase will only be called for doctrine storage.');
2626
}
2727

2828
$task = $this->createTask();
@@ -37,7 +37,7 @@ public function testFindBySystemKey()
3737
public function testFindBySystemKeyNotFound()
3838
{
3939
if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) {
40-
return $this->markTestSkipped('This testcase will only be called for doctrine storage.');
40+
$this->markTestSkipped('This testcase will only be called for doctrine storage.');
4141
}
4242

4343
$task = $this->createTask();
@@ -49,7 +49,7 @@ public function testFindBySystemKeyNotFound()
4949
public function testFindSystemTasks()
5050
{
5151
if ('doctrine' !== self::$kernel->getContainer()->getParameter('kernel.storage')) {
52-
return $this->markTestSkipped('This testcase will only be called for doctrine storage.');
52+
$this->markTestSkipped('This testcase will only be called for doctrine storage.');
5353
}
5454

5555
$task1 = $this->createTask();

tests/Functional/Handler/TaskHandlerFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TaskHandlerFactoryTest extends KernelTestCase
2626
*/
2727
private $taskHandlerFactory;
2828

29-
protected function setUp()
29+
protected function setUp(): void
3030
{
3131
parent::setUp();
3232

tests/Unit/Builder/TaskBuilderFactoryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
namespace Unit\Builder;
44

55
use PHPUnit\Framework\TestCase;
6+
use Prophecy\PhpUnit\ProphecyTrait;
67
use Task\Scheduler\TaskSchedulerInterface;
78
use Task\TaskBundle\Builder\TaskBuilder;
89
use Task\TaskBundle\Builder\TaskBuilderFactory;
910
use Task\TaskInterface;
1011

1112
class TaskBuilderFactoryTest extends TestCase
1213
{
14+
use ProphecyTrait;
15+
1316
public function testCreate()
1417
{
1518
$task = $this->prophesize(TaskInterface::class);

0 commit comments

Comments
 (0)