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('');

0 commit comments

Comments
 (0)