Skip to content

Commit 8c29817

Browse files
committed
[TwigComponent] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0
1 parent 1858e73 commit 8c29817

13 files changed

+70
-77
lines changed

src/TwigComponent/.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/TwigComponent/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
"twig/twig": "^3.10.3"
3535
},
3636
"require-dev": {
37+
"phpunit/phpunit": "^11.1|^12.0",
3738
"symfony/console": "^6.4|^7.0|^8.0",
3839
"symfony/css-selector": "^6.4|^7.0|^8.0",
3940
"symfony/dom-crawler": "^6.4|^7.0|^8.0",
4041
"symfony/framework-bundle": "^6.4|^7.0|^8.0",
41-
"symfony/phpunit-bridge": "^7.2|^8.0",
4242
"symfony/stimulus-bundle": "^2.9.1",
4343
"symfony/twig-bundle": "^6.4|^7.0|^8.0"
4444
},

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

Lines changed: 15 additions & 9 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"
7-
bootstrap="vendor/autoload.php"
7+
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\TwigComponent\Tests\Fixtures\Kernel"/>
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/TwigComponent/tests/Integration/ComponentEventTest.php

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

1212
namespace Symfony\UX\TwigComponent\Tests\Integration;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Twig\Environment;
1617
use Twig\Loader\ArrayLoader;
@@ -22,9 +23,7 @@
2223
*/
2324
final class ComponentEventTest extends KernelTestCase
2425
{
25-
/**
26-
* @dataProvider provideFooBarSyntaxes
27-
*/
26+
#[DataProvider('provideFooBarSyntaxes')]
2827
public function testTemplateIsUpdatedByEventListener(string $syntax)
2928
{
3029
/** @var Environment $environment */

src/TwigComponent/tests/Integration/ComponentExtensionTest.php

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

1212
namespace Symfony\UX\TwigComponent\Tests\Integration;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Symfony\UX\TwigComponent\Tests\Fixtures\User;
1617
use Twig\Environment;
@@ -219,9 +220,7 @@ public function testComponentPropsWithTrailingComma()
219220
$this->assertStringContainsString('Hello FOO, 123, and 456', $output);
220221
}
221222

222-
/**
223-
* @dataProvider renderingAttributesManuallyProvider
224-
*/
223+
#[DataProvider('renderingAttributesManuallyProvider')]
225224
public function testRenderingAttributesManually(array $attributes, string $expected)
226225
{
227226
$actual = trim($this->renderComponent('RenderAttributes', $attributes));
@@ -303,9 +302,7 @@ public function testRenderingComponentWithNestedAttributes()
303302
);
304303
}
305304

306-
/**
307-
* @dataProvider providePrefixedAttributesCases
308-
*/
305+
#[DataProvider('providePrefixedAttributesCases')]
309306
public function testRenderPrefixedAttributes(string $attributes, bool $expectContains)
310307
{
311308
/** @var Environment $twig */
@@ -422,9 +419,7 @@ public function testComponentWithEmptyProps()
422419
$this->assertStringContainsString('I have an empty props tag', $output);
423420
}
424421

425-
/**
426-
* @dataProvider provideUnsafeAttributes
427-
*/
422+
#[DataProvider('provideUnsafeAttributes')]
428423
public function testHtmlSyntaxEscapesAttributeValues(string $input)
429424
{
430425
$output = self::getContainer()->get(Environment::class)->render(
@@ -436,9 +431,7 @@ public function testHtmlSyntaxEscapesAttributeValues(string $input)
436431
$this->assertStringContainsString('&lt;scr', $output);
437432
}
438433

439-
/**
440-
* @dataProvider provideUnsafeAttributes
441-
*/
434+
#[DataProvider('provideUnsafeAttributes')]
442435
public function testDynamicSyntaxEscapesAttributeValues(string $input)
443436
{
444437
$output = self::getContainer()->get(Environment::class)->render(

src/TwigComponent/tests/Integration/ComponentFactoryTest.php

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

1212
namespace Symfony\UX\TwigComponent\Tests\Integration;
1313

14+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
15+
use PHPUnit\Framework\Attributes\TestWith;
1416
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1517
use Symfony\Component\DependencyInjection\Exception\LogicException;
1618
use Symfony\UX\TwigComponent\ComponentFactory;
17-
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\BasicComponent;
1819
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentA;
1920
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentB;
2021
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentC;
@@ -204,13 +205,11 @@ public function testCannotGetConfigByNameForNonRegisteredComponent()
204205
$this->factory()->metadataFor('tabler');
205206
}
206207

207-
/**
208-
* @testWith ["tabler", "Unknown component \"tabler\". Did you mean this: \"table\"?"]
209-
* ["Basic", "Unknown component \"Basic\". Did you mean this: \"BasicComponent\"?"]
210-
* ["basic", "Unknown component \"basic\". Did you mean this: \"BasicComponent\"?"]
211-
* ["with", "Unknown component \"with\". Did you mean one of these: \"with_attributes\", \"with_exposed_variables\", \"WithSlots\"?"]
212-
* ["anonAnon", "Unknown component \"anonAnon\". And no matching anonymous component template was found."]
213-
*/
208+
#[TestWith(['tabler', 'Unknown component "tabler". Did you mean this: "table"?'])]
209+
#[TestWith(['Basic', 'Unknown component "Basic". Did you mean this: "BasicComponent"?'])]
210+
#[TestWith(['basic', 'Unknown component "basic". Did you mean this: "BasicComponent"?'])]
211+
#[TestWith(['with', 'Unknown component "with". Did you mean one of these: "with_attributes", "with_exposed_variables", "WithSlots"?'])]
212+
#[TestWith(['anonAnon', 'Unknown component "anonAnon". And no matching anonymous component template was found.'])]
214213
public function testCannotGetInvalidComponent(string $name, string $expectedExceptionMessage)
215214
{
216215
$this->expectException(\InvalidArgumentException::class);
@@ -225,9 +224,7 @@ public function testInputPropsStoredOnMountedComponent()
225224
$this->assertSame(['propA' => 'A', 'propB' => 'B'], $mountedComponent->getInputProps());
226225
}
227226

228-
/**
229-
* @doesNotPerformAssertions
230-
*/
227+
#[DoesNotPerformAssertions]
231228
public function testGetComponentWithClassName()
232229
{
233230
$factory = $this->factory();

src/TwigComponent/tests/Integration/Test/InteractsWithTwigComponentsTest.php

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

1212
namespace Symfony\UX\TwigComponent\Tests\Integration\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Symfony\UX\TwigComponent\Test\InteractsWithTwigComponents;
1617
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentA;
@@ -21,9 +22,7 @@ final class InteractsWithTwigComponentsTest extends KernelTestCase
2122
{
2223
use InteractsWithTwigComponents;
2324

24-
/**
25-
* @dataProvider componentANameProvider
26-
*/
25+
#[DataProvider('componentANameProvider')]
2726
public function testCanMountComponent(string $name)
2827
{
2928
$component = $this->mountTwigComponent($name, [
@@ -37,9 +36,7 @@ public function testCanMountComponent(string $name)
3736
$this->assertSame('prop b value', $component->getPropB());
3837
}
3938

40-
/**
41-
* @dataProvider componentANameProvider
42-
*/
39+
#[DataProvider('componentANameProvider')]
4340
public function testCanRenderComponent(string $name)
4441
{
4542
$rendered = $this->renderTwigComponent($name, [
@@ -53,9 +50,7 @@ public function testCanRenderComponent(string $name)
5350
$this->assertCount(2, $rendered->crawler()->filter('ul li'));
5451
}
5552

56-
/**
57-
* @dataProvider withSlotsNameProvider
58-
*/
53+
#[DataProvider('withSlotsNameProvider')]
5954
public function testCanRenderComponentWithSlots(string $name)
6055
{
6156
$rendered = $this->renderTwigComponent(

src/TwigComponent/tests/Integration/Twig/ComponentParserTest.php

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

1212
namespace Symfony\UX\TwigComponent\Tests\Integration\Twig;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Twig\Environment;
1617
use Twig\Error\SyntaxError;
@@ -24,9 +25,7 @@
2425
*/
2526
final class ComponentParserTest extends KernelTestCase
2627
{
27-
/**
28-
* @dataProvider provideValidComponentNames
29-
*/
28+
#[DataProvider('provideValidComponentNames')]
3029
public function testAcceptTwigComponentTagWithValidComponentName(string $name)
3130
{
3231
$environment = $this->createEnvironment();
@@ -37,9 +36,7 @@ public function testAcceptTwigComponentTagWithValidComponentName(string $name)
3736
$this->assertInstanceOf(TemplateWrapper::class, $template);
3837
}
3938

40-
/**
41-
* @dataProvider provideValidComponentNames
42-
*/
39+
#[DataProvider('provideValidComponentNames')]
4340
public function testAcceptHtmlComponentTagWithValidComponentName(string $name)
4441
{
4542
$environment = $this->createEnvironment();
@@ -50,9 +47,7 @@ public function testAcceptHtmlComponentTagWithValidComponentName(string $name)
5047
$this->assertInstanceOf(TemplateWrapper::class, $template);
5148
}
5249

53-
/**
54-
* @dataProvider provideValidComponentNames
55-
*/
50+
#[DataProvider('provideValidComponentNames')]
5651
public function testAcceptHtmlSelfClosingComponentTagWithValidComponentName(string $name)
5752
{
5853
$environment = $this->createEnvironment();

src/TwigComponent/tests/Integration/Twig/ComponentPropsParserTest.php

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

1212
namespace Symfony\UX\TwigComponent\Tests\Integration\Twig;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Symfony\UX\TwigComponent\Twig\PropsNode;
1617
use Twig\Environment;
@@ -25,9 +26,7 @@
2526
*/
2627
class ComponentPropsParserTest extends KernelTestCase
2728
{
28-
/**
29-
* @dataProvider providePropsData
30-
*/
29+
#[DataProvider('providePropsData')]
3130
public function testPropsData(string $template, array $props, string $text)
3231
{
3332
$loader = new ArrayLoader(['template' => $template]);

src/TwigComponent/tests/Unit/ComponentAttributesTest.php

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

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

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\UX\StimulusBundle\Dto\StimulusAttributes;
1617
use Symfony\UX\TwigComponent\ComponentAttributes;
@@ -227,9 +228,7 @@ public function testConvertTrueAriaAttributeValue()
227228
$attributes->render('aria-bar');
228229
}
229230

230-
/**
231-
* @dataProvider provideSpecialSyntaxAttributeNames
232-
*/
231+
#[DataProvider('provideSpecialSyntaxAttributeNames')]
233232
public function testAllowsSpecialSyntaxAttributeNames(string $name)
234233
{
235234
$attributes = new ComponentAttributes([$name => 'value'], new EscaperRuntime());
@@ -253,9 +252,7 @@ public function testThrowsTypeErrorWithoutEscaperRuntime()
253252
new ComponentAttributes([]);
254253
}
255254

256-
/**
257-
* @dataProvider nameProvider
258-
*/
255+
#[DataProvider('nameProvider')]
259256
public function testEscapeName(string $input, string $expected)
260257
{
261258
$runtime = new EscaperRuntime();
@@ -264,9 +261,7 @@ public function testEscapeName(string $input, string $expected)
264261
$this->assertSame(' '.$expected.'="foo"', (string) $attributes);
265262
}
266263

267-
/**
268-
* @dataProvider valueProvider
269-
*/
264+
#[DataProvider('valueProvider')]
270265
public function testEscapeValue(string $input, string $expected)
271266
{
272267
$runtime = new EscaperRuntime();

0 commit comments

Comments
 (0)