Skip to content

Commit 0c874bd

Browse files
author
Léa Crémier
committed
update to symfony ^7.0
1 parent 745a735 commit 0c874bd

7 files changed

Lines changed: 94 additions & 75 deletions

File tree

.github/workflows/unit-tests.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,49 @@ jobs:
1313
strategy:
1414
matrix:
1515
include:
16-
- php: '8.0'
16+
- php: '8.2'
1717
mode: low-deps
18-
- php: '8.1'
19-
mode: high-deps
2018
- php: '8.2'
21-
#mode: experimental
19+
- php: '8.3'
20+
- php: '8.4'
21+
mode: high-deps
2222
fail-fast: false
2323

24-
runs-on: ubuntu-20.04
24+
runs-on: ubuntu-24.04
2525
steps:
26-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2727

28-
- name: Cache Composer packages
28+
- name: Get Composer cache dir
2929
id: composer-cache
30-
uses: actions/cache@v3
30+
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT
31+
32+
- name: Cache Composer
33+
uses: actions/cache@v4
3134
with:
32-
path: vendor
33-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
35+
path: ${{ steps.composer-cache.outputs.dir }}
36+
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.mode }}-${{ hashFiles('**/composer.json') }}
3437
restore-keys: |
35-
${{ runner.os }}-php-
38+
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.mode }}-
39+
${{ runner.os }}-composer-${{ matrix.php }}-
40+
${{ runner.os }}-composer-
41+
3642
- name: Install Dependencies
3743
run: |
38-
if [[ "${{ matrix.mode }}" = low-deps ]]; then
39-
COMPOSER_OPTIONS="--prefer-lowest"
44+
if [[ "${{ matrix.mode }}" == "low-deps" ]]; then
45+
# Force LTS of Bridge to avoid the bootstrapping big in prefer-lowest
46+
composer require --no-update --dev symfony/phpunit-bridge:^6.4
47+
COMPOSER_OPTIONS="--prefer-lowest --prefer-stable"
48+
# in case of previously cache vendor folder
49+
rm -rf vendor
4050
fi
4151
composer update --ansi --no-interaction --no-scripts --prefer-dist $COMPOSER_OPTIONS
4252
53+
- name: Audit Security
54+
run: composer audit
55+
4356
- name: Execute tests (Unit and Feature tests) via PHPUnit
44-
run: ./vendor/bin/simple-phpunit
57+
env:
58+
SYMFONY_PHPUNIT_VERSION: ${{ matrix.mode == 'low-deps' && '9.5' || '' }}
59+
run: |
60+
composer config --global use-parent-dir false
61+
./vendor/bin/simple-phpunit

DependencyInjection/DeamonLoggerExtraExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Symfony\Component\Config\FileLocator;
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Extension\Extension;
78
use Symfony\Component\DependencyInjection\Loader;
8-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
99

1010
/**
1111
* This is the class that loads and manages your bundle configuration.

Tests/DependencyInjection/DeamonLoggerExtraExtensionTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function setUp(): void
3232
$this->container = new ContainerBuilder();
3333
}
3434

35-
public function testLoad()
35+
public function testLoad(): void
3636
{
3737
$configs = [
3838
$this->getValidConfigFull(),
@@ -57,7 +57,7 @@ public function testLoad()
5757
$this->assertEquals('bar', $tag[0]['handler']);
5858
}
5959

60-
public function testDefaultValue()
60+
public function testDefaultValue(): void
6161
{
6262
$configs = [
6363
$this->getValidConfigMin(),
@@ -98,7 +98,7 @@ public function testDefaultValue()
9898
$this->assertEquals($defaultConfigValues, $definition2->getArgument(0));
9999
}
100100

101-
public function testConvertStringHandlerToArray()
101+
public function testConvertStringHandlerToArray(): void
102102
{
103103
$configs = [
104104
[
@@ -123,7 +123,7 @@ public function testConvertStringHandlerToArray()
123123
/**
124124
* @return array
125125
*/
126-
private function getValidConfigFull()
126+
private function getValidConfigFull(): array
127127
{
128128
return [
129129
'application' => [
@@ -155,10 +155,7 @@ private function getValidConfigFull()
155155
];
156156
}
157157

158-
/**
159-
* @return array
160-
*/
161-
private function getValidConfigMin()
158+
private function getValidConfigMin(): array
162159
{
163160
return [
164161
'application' => null,

Tests/Processors/Monolog/DeamonLoggerExtraWebProcessorTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class DeamonLoggerExtraWebProcessorTest extends TestCase
1515
{
1616

17-
public function testProcessorWithNullContainer()
17+
public function testProcessorWithNullContainer(): void
1818
{
1919
$processor = new DeamonLoggerExtraWebProcessor();
2020
$originalRecord = $this->getRecord();
@@ -26,7 +26,7 @@ public function testProcessorWithNullContainer()
2626
/**
2727
* @runInSeparateProcess
2828
*/
29-
public function testAddContextInfo()
29+
public function testAddContextInfo(): void
3030
{
3131
$config = $this->getDisplayConfig([
3232
'env' => true,
@@ -49,7 +49,7 @@ public function testAddContextInfo()
4949
/**
5050
* @runInSeparateProcess
5151
*/
52-
public function testAddContextInfoWithoutLocaleAndVersion()
52+
public function testAddContextInfoWithoutLocaleAndVersion(): void
5353
{
5454
$config = $this->getDisplayConfig([
5555
'env' => true,
@@ -69,7 +69,7 @@ public function testAddContextInfoWithoutLocaleAndVersion()
6969
$this->assertArrayHasKeyAndEquals('application', $record->extra, 'foo_app');
7070
}
7171

72-
public function testAddRequestInfo()
72+
public function testAddRequestInfo(): void
7373
{
7474
$config = $this->getDisplayConfig(
7575
[
@@ -92,7 +92,7 @@ public function testAddRequestInfo()
9292
$this->assertArrayHasKeyAndEquals('client_ip', $record->extra, '123.456.789.123');
9393
}
9494

95-
public function testAddOnlyUserInfoOnDefinedClass()
95+
public function testAddOnlyUserInfoOnDefinedClass(): void
9696
{
9797
$config = $this->getDisplayConfig([
9898
'user' => true,
@@ -109,7 +109,7 @@ public function testAddOnlyUserInfoOnDefinedClass()
109109
$this->assertArrayNotHasKey('user_name', $record->extra);
110110
}
111111

112-
public function testAddUserInfoWithNotExistingClass()
112+
public function testAddUserInfoWithNotExistingClass(): void
113113
{
114114
$config = $this->getDisplayConfig([
115115
'user' => true,
@@ -121,7 +121,7 @@ public function testAddUserInfoWithNotExistingClass()
121121
$this->assertArrayNotHasKey('user_name', $record->extra);
122122
}
123123

124-
public function testAddUserInfoWithNullClass()
124+
public function testAddUserInfoWithNullClass(): void
125125
{
126126
$config = $this->getDisplayConfig([
127127
'user' => true,
@@ -133,7 +133,7 @@ public function testAddUserInfoWithNullClass()
133133
$this->assertArrayNotHasKey('user_name', $record->extra);
134134
}
135135

136-
public function testAddUserinfoWithNoTokenStorage()
136+
public function testAddUserinfoWithNoTokenStorage(): void
137137
{
138138
$config = $this->getDisplayConfig([
139139
'user' => true,
@@ -145,7 +145,7 @@ public function testAddUserinfoWithNoTokenStorage()
145145
$this->assertArrayNotHasKey('user_name', $record->extra);
146146
}
147147

148-
public function testAddUserInfo()
148+
public function testAddUserInfo(): void
149149
{
150150
$config = $this->getDisplayConfig([
151151
'user' => true,
@@ -164,7 +164,7 @@ public function testAddUserInfo()
164164
$this->assertArrayHasKeyAndEquals('user_name', $record->extra, 'foo');
165165
}
166166

167-
protected function getDisplayConfig($trueValues, $channelPrefix = null, $user_class = '\Symfony\Component\Security\Core\User\UserInterface', $user_methods = null)
167+
protected function getDisplayConfig($trueValues, $channelPrefix = null, $user_class = '\Symfony\Component\Security\Core\User\UserInterface', $user_methods = null): array
168168
{
169169
if (!is_array($user_methods)) {
170170
$user_methods = [
@@ -195,13 +195,13 @@ protected function getDisplayConfig($trueValues, $channelPrefix = null, $user_cl
195195
];
196196
}
197197

198-
protected function assertArrayHasKeyAndEquals($key, $array, $value, $message = '')
198+
protected function assertArrayHasKeyAndEquals($key, $array, $value, $message = ''): void
199199
{
200200
$this->assertArrayHasKey($key, $array);
201201
$this->assertEquals($value, $array[$key], $message);
202202
}
203203

204-
private function getRequestStack()
204+
private function getRequestStack(): RequestStack
205205
{
206206
$request = new Request([], [], [
207207
'_route' => 'requested_route',
@@ -217,12 +217,12 @@ private function getRequestStack()
217217
return $stack;
218218
}
219219

220-
private function getLoggerExtraContext($locale = 'fr', $version = null)
220+
private function getLoggerExtraContext($locale = 'fr', $version = null): DeamonLoggerExtraContext
221221
{
222222
return new DeamonLoggerExtraContext('foo_app', $locale, $version);
223223
}
224224

225-
private function getTokenStorage(UserInterface $user = null)
225+
private function getTokenStorage(?UserInterface $user = null): TokenStorage
226226
{
227227
$storage = new TokenStorage();
228228
$storage->setToken(new MyToken($user));
@@ -265,7 +265,7 @@ public function getSalt(): ?string
265265
//not needed in tests
266266
}
267267

268-
public function eraseCredentials()
268+
public function eraseCredentials(): void
269269
{
270270
//not needed in tests
271271
}

Tests/Services/DeamonLoggerExtraContextTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class DeamonLoggerExtraContextTest extends TestCase
1212
*
1313
* @param string $locale
1414
*/
15-
public function testGetLocale($locale)
15+
public function testGetLocale($locale): void
1616
{
1717
$context = new DeamonLoggerExtraContext('', $locale);
1818
$this->assertEquals($locale, $context->getLocale(), sprintf('locale should be %s, %s returned.', $locale, $context->getLocale()));
1919
}
2020

21-
public function getLocaleDataset()
21+
public function getLocaleDataset(): array
2222
{
2323
return [
2424
['fr', 'locale should be fr'],
@@ -31,13 +31,13 @@ public function getLocaleDataset()
3131
*
3232
* @param $applicationName
3333
*/
34-
public function testGetApplicationName($applicationName)
34+
public function testGetApplicationName($applicationName): void
3535
{
3636
$context = new DeamonLoggerExtraContext($applicationName, 'fr');
3737
$this->assertEquals($applicationName, $context->getApplicationName(), sprintf('application_name should be %s, %s returned.', $applicationName, $context->getApplicationName()));
3838
}
3939

40-
public function getApplicationNameDataset()
40+
public function getApplicationNameDataset(): array
4141
{
4242
return [
4343
['github.com/deamon'],

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
"Log"
1818
],
1919
"require": {
20-
"php": ">=8.0.2",
21-
"symfony/security-core": "^6.0",
22-
"symfony/dependency-injection": "^6.0",
23-
"symfony/monolog-bridge": "^6.0",
20+
"php": ">=8.2",
21+
"symfony/security-core": "^7.0",
22+
"symfony/dependency-injection": "^7.0",
23+
"symfony/monolog-bridge": "^7.0",
2424
"monolog/monolog": "^3.0",
25-
"symfony/http-kernel": "^6.0",
26-
"symfony/http-foundation": "^6.0",
27-
"symfony/config": "^6.0"
25+
"symfony/http-kernel": "^7.0",
26+
"symfony/http-foundation": "^7.2",
27+
"symfony/config": "^7.0"
2828
},
2929
"require-dev": {
30-
"symfony/phpunit-bridge": "^6.0"
30+
"symfony/phpunit-bridge": "^7.0"
3131
},
3232
"autoload": {
3333
"psr-4": {
@@ -36,7 +36,7 @@
3636
},
3737
"extra": {
3838
"branch-alias": {
39-
"dev-master": "6.0.x-dev"
39+
"dev-master": "7.0.x-dev"
4040
}
4141
},
4242
"suggest": {

phpunit.xml.dist

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<php>
4-
<!-- authorize extending Monolog/logger final class -->
5-
<server name="SYMFONY_DEPRECATIONS_HELPER" value="1" />
6-
</php>
7-
<coverage>
8-
<include>
9-
<directory>.</directory>
10-
</include>
11-
<exclude>
12-
<directory>./Resources</directory>
13-
<directory>./Tests</directory>
14-
<directory>./vendor</directory>
15-
</exclude>
16-
</coverage>
17-
<testsuites>
18-
<testsuite name="LoggerExtraBundle for Symfony">
19-
<directory>./Tests</directory>
20-
</testsuite>
21-
</testsuites>
22-
<php>
23-
<server name="KERNEL_CLASS" value="App\Kernel"/>
24-
<ini name="date.timezone" value="UTC"/>
25-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
colors="true"
4+
bootstrap="vendor/autoload.php"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
6+
>
7+
<coverage>
8+
<include>
9+
<directory>.</directory>
10+
</include>
11+
<exclude>
12+
<directory>./Resources</directory>
13+
<directory>./Tests</directory>
14+
<directory>./vendor</directory>
15+
</exclude>
16+
</coverage>
17+
<testsuites>
18+
<testsuite name="LoggerExtraBundle for Symfony">
19+
<directory>./Tests</directory>
20+
</testsuite>
21+
</testsuites>
22+
<listeners>
23+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
24+
</listeners>
25+
<php>
26+
<server name="KERNEL_CLASS" value="App\Kernel"/>
27+
<ini name="date.timezone" value="UTC"/>
28+
<server name="SYMFONY_DEPRECATIONS_HELPER" value="1"/>
29+
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
30+
</php>
2631
</phpunit>

0 commit comments

Comments
 (0)