Skip to content

Commit 5f75caf

Browse files
committed
Upgrade to PHP 8.1 & PHPUnit 12
1 parent f356aa3 commit 5f75caf

29 files changed

+207
-202
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ name: "CI"
33
on:
44
pull_request:
55
push:
6-
branches:
7-
- '1.x'
8-
- '2.x'
9-
10-
env:
11-
SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
126

137
jobs:
148
tests:
@@ -20,9 +14,8 @@ jobs:
2014
fail-fast: false
2115
matrix:
2216
include:
23-
- php: '8.0'
24-
composer: 2.2.x
2517
- php: '8.1'
18+
composer: 2.2.x
2619
- php: '8.2'
2720
- php: '8.3'
2821
- php: '8.4'
@@ -40,7 +33,7 @@ jobs:
4033
php-version: ${{ matrix.php }}
4134
tools: composer:${{ matrix.composer }}
4235

43-
- if: matrix.php == '8.0'
36+
- if: matrix.php == '8.1'
4437
name: "Lint PHP files"
4538
run: |
4639
find src/ -name '*.php' | xargs -n1 php -l
@@ -57,7 +50,5 @@ jobs:
5750
composer u --ansi
5851
fi
5952
60-
- name: "Install PHPUnit"
61-
run: vendor/bin/simple-phpunit install
62-
63-
- run: vendor/bin/simple-phpunit
53+
- name: "Run tests"
54+
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/vendor/
22
/build/
3-
.phpunit.result.cache
3+
/.phpunit.cache
44
.php_cs.cache
55
composer.lock

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
],
1212
"minimum-stability": "dev",
1313
"require": {
14-
"php": ">=8.0",
14+
"php": ">=8.1",
1515
"composer-plugin-api": "^2.1"
1616
},
1717
"require-dev": {
1818
"composer/composer": "^2.1",
19+
"phpunit/phpunit": "^10.5|^11.5|^12.4",
1920
"symfony/dotenv": "^5.4|^6.0",
2021
"symfony/filesystem": "^5.4|^6.0",
21-
"symfony/phpunit-bridge": "^5.4|^6.0",
2222
"symfony/process": "^5.4|^6.0"
2323
},
2424
"conflict": {

phpunit.xml.dist

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit backupGlobals="true"
4-
backupStaticAttributes="false"
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="true"
56
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
7+
failOnNotice="true"
8+
failOnWarning="true"
119
bootstrap="tests/bootstrap.php"
10+
cacheDirectory=".phpunit.cache"
1211
>
13-
<testsuites>
14-
<testsuite name="Symfony Flex Test Suite">
15-
<directory>./tests</directory>
16-
</testsuite>
17-
</testsuites>
12+
<testsuites>
13+
<testsuite name="Symfony Flex Test Suite">
14+
<directory>./tests</directory>
15+
</testsuite>
16+
</testsuites>
1817

19-
<php>
20-
<ini name="error_reporting" value="-1" />
21-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
22-
<env name="LC_ALL" value="C" />
23-
</php>
24-
25-
<filter>
26-
<whitelist>
27-
<directory>./src/</directory>
28-
</whitelist>
29-
</filter>
18+
<php>
19+
<ini name="error_reporting" value="-1" />
20+
</php>
3021
</phpunit>

src/Command/DumpEnvCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(Config $config, Options $options)
3333
parent::__construct();
3434
}
3535

36-
protected function configure()
36+
protected function configure(): void
3737
{
3838
$this->setName('symfony:dump-env')
3939
->setAliases(['dump-env'])

src/Command/InstallRecipesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(/* cannot be type-hinted */ $flex, string $rootDir,
3838
parent::__construct();
3939
}
4040

41-
protected function configure()
41+
protected function configure(): void
4242
{
4343
$this->setName('symfony:recipes:install')
4444
->setAliases(['recipes:install', 'symfony:sync-recipes', 'sync-recipes', 'fix-recipes'])

src/Command/RecipesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(/* cannot be type-hinted */ $flex, Lock $symfonyLock
4444
parent::__construct();
4545
}
4646

47-
protected function configure()
47+
protected function configure(): void
4848
{
4949
$this->setName('symfony:recipes')
5050
->setAliases(['recipes'])

src/Command/UpdateRecipesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(/* cannot be type-hinted */ $flex, Downloader $downl
5151
parent::__construct();
5252
}
5353

54-
protected function configure()
54+
protected function configure(): void
5555
{
5656
$this->setName('symfony:recipes:update')
5757
->setAliases(['recipes:update'])

src/Flex.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,12 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
197197
BasePackage::$stabilities['dev'] = 1 + BasePackage::STABILITY_STABLE;
198198
}
199199

200-
$app->add(new Command\RecipesCommand($this, $this->lock, $rfs));
201-
$app->add(new Command\InstallRecipesCommand($this, $this->options->get('root-dir'), $this->options->get('runtime')['dotenv_path'] ?? '.env'));
202-
$app->add(new Command\UpdateRecipesCommand($this, $this->downloader, $rfs, $this->configurator, $this->options->get('root-dir')));
203-
$app->add(new Command\DumpEnvCommand($this->config, $this->options));
200+
$app->addCommands([
201+
new Command\RecipesCommand($this, $this->lock, $rfs),
202+
new Command\InstallRecipesCommand($this, $this->options->get('root-dir'), $this->options->get('runtime')['dotenv_path'] ?? '.env'),
203+
new Command\UpdateRecipesCommand($this, $this->downloader, $rfs, $this->configurator, $this->options->get('root-dir')),
204+
new Command\DumpEnvCommand($this->config, $this->options),
205+
]);
204206

205207
break;
206208
}

tests/Command/DumpEnvCommandTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use Composer\Config;
1515
use Composer\Console\Application;
16+
use PHPUnit\Framework\Attributes\BackupGlobals;
17+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1618
use PHPUnit\Framework\TestCase;
1719
use Symfony\Component\Console\Tester\CommandTester;
1820
use Symfony\Flex\Command\DumpEnvCommand;
@@ -82,9 +84,7 @@ public function testEmptyOptionMustIgnoreContent()
8284
unlink($envLocal);
8385
}
8486

85-
/**
86-
* @backupGlobals enabled
87-
*/
87+
#[BackupGlobals(true)]
8888
public function testEnvCanBeReferenced()
8989
{
9090
@mkdir(FLEX_TEST_DIR);
@@ -164,9 +164,7 @@ public function testDoesNotRequireToSpecifyEnvArgumentWhenLocalFileIsPresent()
164164
unlink($envLocalPhp);
165165
}
166166

167-
/**
168-
* @runInSeparateProcess
169-
*/
167+
#[RunInSeparateProcess]
170168
public function testLoadLocalEnvWhenTestEnvIsNotEqual()
171169
{
172170
@mkdir(FLEX_TEST_DIR);
@@ -210,7 +208,11 @@ private function createCommandDumpEnv(array $options = [])
210208
);
211209

212210
$application = new Application();
213-
$application->add($command);
211+
if (method_exists($application, 'addCommand')) {
212+
$application->addCommand($command);
213+
} else {
214+
$application->add($command);
215+
}
214216
$command = $application->find('dump-env');
215217

216218
return new CommandTester($command);

0 commit comments

Comments
 (0)