Skip to content

Commit cbc0f2c

Browse files
committed
[Icons] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0
1 parent f5c1b6d commit cbc0f2c

File tree

10 files changed

+50
-74
lines changed

10 files changed

+50
-74
lines changed

src/Icons/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/vendor/
33
/composer.lock
44
/phpunit.xml
5-
/.phpunit.result.cache
5+
/.phpunit.cache
66

77
/var
8+
/config/reference.php

src/Icons/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
"symfony/twig-bundle": "^6.4|^7.0|^8.0"
4141
},
4242
"require-dev": {
43+
"phpunit/phpunit": "^11.1|^12.0",
4344
"symfony/asset-mapper": "^6.4|^7.0|^8.0",
4445
"symfony/console": "^6.4|^7.0|^8.0",
4546
"symfony/http-client": "^6.4|^7.0|^8.0",
46-
"symfony/phpunit-bridge": "^7.2|^8.0",
4747
"symfony/ux-twig-component": "^2.14",
4848
"zenstruck/console-test": "^1.5",
4949
"psr/log": "^2|^3"

src/Icons/phpunit.xml.dist renamed to src/Icons/phpunit.dist.xml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
33
<phpunit
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="vendor/bin/.phpunit/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
66
colors="true"
77
bootstrap="tests/bootstrap.php"
8+
failOnDeprecation="true"
89
failOnRisky="true"
910
failOnWarning="true"
11+
cacheDirectory=".phpunit.cache"
1012
>
1113
<php>
1214
<ini name="error_reporting" value="-1"/>
1315
<env name="SHELL_VERBOSITY" value="-1"/>
14-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0"/>
1516
<env name="KERNEL_CLASS" value="Symfony\UX\Icons\Tests\Fixtures\TestKernel" />
1617
</php>
1718

@@ -21,13 +22,18 @@
2122
</testsuite>
2223
</testsuites>
2324

24-
<coverage>
25+
<source
26+
ignoreSuppressionOfDeprecations="true"
27+
ignoreIndirectDeprecations="true"
28+
restrictNotices="true"
29+
restrictWarnings="true"
30+
>
2531
<include>
26-
<directory>./src</directory>
32+
<directory>src</directory>
2733
</include>
28-
</coverage>
2934

30-
<listeners>
31-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
32-
</listeners>
35+
<deprecationTrigger>
36+
<function>trigger_deprecation</function>
37+
</deprecationTrigger>
38+
</source>
3339
</phpunit>

src/Icons/tests/Integration/Command/ImportIconCommandTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\UX\Icons\Tests\Integration\Command;
1313

14+
use PHPUnit\Framework\Attributes\After;
15+
use PHPUnit\Framework\Attributes\Before;
1416
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1517
use Symfony\Component\Filesystem\Filesystem;
1618
use Zenstruck\Console\Test\InteractsWithConsole;
@@ -25,11 +27,8 @@ final class ImportIconCommandTest extends KernelTestCase
2527
private const ICON_DIR = __DIR__.'/../../Fixtures/icons';
2628
private const ICONS = ['uiw/dashboard.svg', 'lucide/circle.svg'];
2729

28-
/**
29-
* @before
30-
*
31-
* @after
32-
*/
30+
#[Before]
31+
#[After]
3332
public static function cleanup(): void
3433
{
3534
$fs = new Filesystem();

src/Icons/tests/Integration/Command/LockIconsCommandTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\UX\Icons\Tests\Integration\Command;
1313

14+
use PHPUnit\Framework\Attributes\After;
15+
use PHPUnit\Framework\Attributes\Before;
1416
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1517
use Symfony\Component\Filesystem\Filesystem;
1618
use Zenstruck\Console\Test\InteractsWithConsole;
@@ -29,11 +31,8 @@ final class LockIconsCommandTest extends KernelTestCase
2931
__DIR__.'/../../Fixtures/icons/lucide/circle-off.svg',
3032
];
3133

32-
/**
33-
* @before
34-
*
35-
* @after
36-
*/
34+
#[Before]
35+
#[After]
3736
public static function cleanup(): void
3837
{
3938
$fs = new Filesystem();

src/Icons/tests/Unit/IconRendererTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\UX\Icons\Tests\Unit;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\UX\Icons\Exception\IconNotFoundException;
1617
use Symfony\UX\Icons\Icon;
@@ -81,9 +82,7 @@ public function testRenderIconWithDefaultAttributes()
8182
$this->assertSame('<svg viewBox="0 0 24 24" class="icon" aria-hidden="true"><path d="M0 0L12 12"/></svg>', $svg);
8283
}
8384

84-
/**
85-
* @dataProvider provideRenderIconWithAttributeCascadeCases
86-
*/
85+
#[DataProvider('provideRenderIconWithAttributeCascadeCases')]
8786
public function testRenderIconWithAttributeCascade(
8887
array $iconAttributes,
8988
array $defaultAttributes = [],
@@ -276,11 +275,10 @@ public static function provideRenderIconWithAttributeCascadeCases(): iterable
276275
}
277276

278277
/**
279-
* @dataProvider provideAriaHiddenCases
280-
*
281278
* @param string|array{string, array<string, string|bool>} $icon
282279
* @param array<string, string|bool> $attributes
283280
*/
281+
#[DataProvider('provideAriaHiddenCases')]
284282
public function testRenderIconWithAutoAriaHidden(string|array $icon, array $attributes, string $expectedSvg)
285283
{
286284
$icon = (array) $icon;
@@ -366,9 +364,8 @@ public function testRenderIconWithAliases()
366364

367365
/**
368366
* @param array<string, string> $attributes
369-
*
370-
* @dataProvider provideRenderIconWithIconSetAttributes
371367
*/
368+
#[DataProvider('provideRenderIconWithIconSetAttributes')]
372369
public function testRenderIconWithIconSetAttributes(string $name, array $attributes, string $expectedSvg)
373370
{
374371
$registry = $this->createRegistry([

src/Icons/tests/Unit/IconTest.php

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\UX\Icons\Tests\Unit;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\UX\Icons\Icon;
1617

@@ -23,17 +24,13 @@ public function testConstructor()
2324
$this->assertSame('bar', $icon->getAttributes()['foo']);
2425
}
2526

26-
/**
27-
* @dataProvider provideIdToName
28-
*/
27+
#[DataProvider('provideIdToName')]
2928
public function testIdToName(string $id, string $name)
3029
{
3130
$this->assertSame($name, Icon::idToName($id));
3231
}
3332

34-
/**
35-
* @dataProvider provideInvalidIds
36-
*/
33+
#[DataProvider('provideInvalidIds')]
3734
public function testIdToNameThrowsException(string $id)
3835
{
3936
$this->expectException(\InvalidArgumentException::class);
@@ -42,17 +39,13 @@ public function testIdToNameThrowsException(string $id)
4239
Icon::idToName($id);
4340
}
4441

45-
/**
46-
* @dataProvider provideNameToId
47-
*/
42+
#[DataProvider('provideNameToId')]
4843
public function testNameToId(string $name, string $id)
4944
{
5045
$this->assertEquals($id, Icon::nameToId($name));
5146
}
5247

53-
/**
54-
* @dataProvider provideInvalidNames
55-
*/
48+
#[DataProvider('provideInvalidNames')]
5649
public function testNameToIdThrowsException(string $name)
5750
{
5851
$this->expectException(\InvalidArgumentException::class);
@@ -61,41 +54,31 @@ public function testNameToIdThrowsException(string $name)
6154
Icon::nameToId($name);
6255
}
6356

64-
/**
65-
* @dataProvider provideValidIds
66-
*/
57+
#[DataProvider('provideValidIds')]
6758
public function testIsValidIdWithValidIds(string $id)
6859
{
6960
$this->assertTrue(Icon::isValidId($id));
7061
}
7162

72-
/**
73-
* @dataProvider provideInvalidIds
74-
*/
63+
#[DataProvider('provideInvalidIds')]
7564
public function testIsValidIdWithInvalidIds(string $id)
7665
{
7766
$this->assertFalse(Icon::isValidId($id));
7867
}
7968

80-
/**
81-
* @dataProvider provideValidNames
82-
*/
69+
#[DataProvider('provideValidNames')]
8370
public function testIsValidNameWithValidNames(string $name)
8471
{
8572
$this->assertTrue(Icon::isValidName($name));
8673
}
8774

88-
/**
89-
* @dataProvider provideInvalidNames
90-
*/
75+
#[DataProvider('provideInvalidNames')]
9176
public function testIsValidNameWithInvalidNames(string $name)
9277
{
9378
$this->assertFalse(Icon::isValidName($name));
9479
}
9580

96-
/**
97-
* @dataProvider provideInvalidIds
98-
*/
81+
#[DataProvider('provideInvalidIds')]
9982
public function testInvalidIdToName(string $id)
10083
{
10184
$this->expectException(\InvalidArgumentException::class);
@@ -105,18 +88,14 @@ public function testInvalidIdToName(string $id)
10588
Icon::idToName($id);
10689
}
10790

108-
/**
109-
* @dataProvider provideRenderAttributesTestCases
110-
*/
91+
#[DataProvider('provideRenderAttributesTestCases')]
11192
public function testRenderAttributes(array $attributes, string $expected)
11293
{
11394
$icon = new Icon('', $attributes);
11495
$this->assertStringStartsWith($expected, $icon->toHtml());
11596
}
11697

117-
/**
118-
* @dataProvider provideWithAttributesTestCases
119-
*/
98+
#[DataProvider('provideWithAttributesTestCases')]
12099
public function testWithAttributes(array $attributes, array $withAttributes, array $expected)
121100
{
122101
$icon = new Icon('foo', $attributes);

src/Icons/tests/Unit/IconifyTest.php

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

1212
namespace Symfony\UX\Icons\Tests\Unit;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Cache\Adapter\NullAdapter;
1617
use Symfony\Component\HttpClient\MockHttpClient;
@@ -279,9 +280,7 @@ public function testGetMetadata()
279280
$this->assertSame('Font Awesome Solid', $metadata['name']);
280281
}
281282

282-
/**
283-
* @dataProvider provideChunkCases
284-
*/
283+
#[DataProvider('provideChunkCases')]
285284
public function testChunk(int $maxQueryLength, string $prefix, array $names, array $chunks)
286285
{
287286
$iconify = new Iconify(

src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\UX\Icons\Tests\Unit\Registry;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\UX\Icons\Icon;
1617
use Symfony\UX\Icons\Registry\LocalSvgIconRegistry;
@@ -20,9 +21,7 @@
2021
*/
2122
final class LocalSvgIconRegistryTest extends TestCase
2223
{
23-
/**
24-
* @dataProvider validSvgProvider
25-
*/
24+
#[DataProvider('validSvgProvider')]
2625
public function testValidSvgs(string $name, array $expectedAttributes, string $expectedContent)
2726
{
2827
$icon = $this->registry()->get($name);
@@ -64,9 +63,7 @@ public static function validSvgProvider(): iterable
6463
];
6564
}
6665

67-
/**
68-
* @dataProvider invalidSvgProvider
69-
*/
66+
#[DataProvider('invalidSvgProvider')]
7067
public function testInvalidSvgs(string $name)
7168
{
7269
$this->expectException(\RuntimeException::class);
@@ -82,9 +79,7 @@ public static function invalidSvgProvider(): iterable
8279
yield ['invalid4'];
8380
}
8481

85-
/**
86-
* @dataProvider provideIconSetPathsCases
87-
*/
82+
#[DataProvider('provideIconSetPathsCases')]
8883
public function testIconSetPaths(string $name, array $iconSetPaths, ?string $expectedContent)
8984
{
9085
$registry = new LocalSvgIconRegistry(

src/Icons/tests/bootstrap.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
use Symfony\Component\Filesystem\Filesystem;
12+
use Symfony\Component\ErrorHandler\ErrorHandler;
1313

1414
require __DIR__.'/../vendor/autoload.php';
1515

16-
(new Filesystem())->remove(__DIR__.'/../var');
16+
// @see https://github.com/symfony/symfony/issues/53812
17+
ErrorHandler::register(null, false);

0 commit comments

Comments
 (0)