Skip to content

Commit 18fbdf9

Browse files
committed
[LiveComponent] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0
1 parent cbc0f2c commit 18fbdf9

14 files changed

+82
-87
lines changed

src/LiveComponent/.gitignore

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

src/LiveComponent/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@
4141
"doctrine/orm": "^2.9.4|^3.0",
4242
"doctrine/persistence": "^2.5.2|^3.0",
4343
"phpdocumentor/reflection-docblock": "5.x-dev",
44+
"phpunit/phpunit": "^11.1|^12.0",
4445
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
4546
"symfony/expression-language": "^6.4|^7.0|^8.0",
4647
"symfony/form": "^6.4|^7.0|^8.0",
4748
"symfony/framework-bundle": "^6.4|^7.0|^8.0",
4849
"symfony/options-resolver": "^6.4|^7.0|^8.0",
49-
"symfony/phpunit-bridge": "^7.2|^8.0",
5050
"symfony/security-bundle": "^6.4|^7.0|^8.0",
5151
"symfony/serializer": "^6.4|^7.0|^8.0",
5252
"symfony/twig-bundle": "^6.4|^7.0|^8.0",
5353
"symfony/uid": "^6.4|^7.0|^8.0",
5454
"symfony/validator": "^6.4|^7.0|^8.0",
55-
"zenstruck/browser": "^1.2.0",
55+
"zenstruck/browser": "^1.9",
5656
"zenstruck/foundry": "^2.0"
5757
},
5858
"conflict": {

src/LiveComponent/phpunit.xml.dist renamed to src/LiveComponent/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&amp;quiet[]=indirect&amp;quiet[]=other"/>
1516
<env name="KERNEL_CLASS" value="Symfony\UX\LiveComponent\Tests\Fixtures\Kernel"/>
1617
<env name="DATABASE_URL" value="sqlite:///%kernel.project_dir%/var/data.db"/>
1718
</php>
@@ -22,13 +23,18 @@
2223
</testsuite>
2324
</testsuites>
2425

25-
<coverage>
26+
<source
27+
ignoreSuppressionOfDeprecations="true"
28+
ignoreIndirectDeprecations="true"
29+
restrictNotices="true"
30+
restrictWarnings="true"
31+
>
2632
<include>
27-
<directory>./src</directory>
33+
<directory>src</directory>
2834
</include>
29-
</coverage>
3035

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

src/LiveComponent/tests/Functional/EventListener/DeferLiveComponentSubscriberTest.php

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

1212
namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;
1617
use Zenstruck\Browser\Test\HasBrowser;
@@ -122,9 +123,7 @@ public function testLazyComponentIsNotRendered()
122123
$this->assertSame('live:appear->live#$render', $div->attr('data-action'));
123124
}
124125

125-
/**
126-
* @dataProvider provideLoadingValues
127-
*/
126+
#[DataProvider('provideLoadingValues')]
128127
public function testLazyComponentRenderingDependsOnLazyValue(mixed $lazy, bool $isRendered)
129128
{
130129
$crawler = $this->browser()

src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php

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

1212
namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener;
1313

14+
use PHPUnit\Framework\Attributes\Group;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Symfony\Component\Security\Core\User\InMemoryUser;
1617
use Symfony\Component\Security\Http\Attribute\IsGranted;
@@ -91,9 +92,7 @@ public function testCanRenderComponentAsHtmlWithAlternateRoute()
9192
;
9293
}
9394

94-
/**
95-
* @group transient-on-windows
96-
*/
95+
#[Group('transient-on-windows')]
9796
public function testCanExecuteComponentActionNormalRoute()
9897
{
9998
$templateName = 'render_embedded_with_blocks.html.twig';
@@ -192,9 +191,7 @@ public function testPreReRenderHookOnlyExecutedDuringAjax()
192191
;
193192
}
194193

195-
/**
196-
* @group transient-on-windows
197-
*/
194+
#[Group('transient-on-windows')]
198195
public function testItAddsEmbeddedTemplateContextToEmbeddedComponents()
199196
{
200197
$templateName = 'render_embedded_with_blocks.html.twig';
@@ -232,9 +229,7 @@ public function testItAddsEmbeddedTemplateContextToEmbeddedComponents()
232229
;
233230
}
234231

235-
/**
236-
* @group transient-on-windows
237-
*/
232+
#[Group('transient-on-windows')]
238233
public function testItWorksWithNamespacedTemplateNamesForEmbeddedComponents()
239234
{
240235
$templateName = 'render_embedded_with_blocks.html.twig';
@@ -248,9 +243,7 @@ public function testItWorksWithNamespacedTemplateNamesForEmbeddedComponents()
248243
;
249244
}
250245

251-
/**
252-
* @group transient-on-windows
253-
*/
246+
#[Group('transient-on-windows')]
254247
public function testItUseBlocksFromEmbeddedContextUsingMultipleComponents()
255248
{
256249
$templateName = 'render_multiple_embedded_with_blocks.html.twig';
@@ -283,9 +276,7 @@ public function testItUseBlocksFromEmbeddedContextUsingMultipleComponents()
283276
;
284277
}
285278

286-
/**
287-
* @group transient-on-windows
288-
*/
279+
#[Group('transient-on-windows')]
289280
public function testItUseBlocksFromEmbeddedContextUsingMultipleComponentsWithNamespacedTemplate()
290281
{
291282
$templateName = 'render_multiple_embedded_with_blocks.html.twig';

src/LiveComponent/tests/Functional/EventListener/LiveUrlSubscriberTest.php

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

1212
namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address;
1617
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;
@@ -21,7 +22,7 @@ class LiveUrlSubscriberTest extends KernelTestCase
2122
use HasBrowser;
2223
use LiveComponentTestHelper;
2324

24-
public function getTestData(): iterable
25+
public static function getTestData(): iterable
2526
{
2627
yield 'Missing header' => [
2728
'previousLocation' => null,
@@ -229,16 +230,14 @@ public function getTestData(): iterable
229230
];
230231
}
231232

232-
/**
233-
* @dataProvider getTestData
234-
*/
233+
#[DataProvider('getTestData')]
235234
public function testNewLiveUrlAfterLiveAction(
236235
?string $previousLocation,
237236
?string $expectedLocation,
238-
array $initalComponentData,
237+
array $initialComponentData,
239238
array $args,
240239
): void {
241-
$component = $this->mountComponent('component_with_url_bound_props', $initalComponentData);
240+
$component = $this->mountComponent('component_with_url_bound_props', $initialComponentData);
242241
$dehydrated = $this->dehydrateComponent($component);
243242

244243
$this->browser()

src/LiveComponent/tests/Functional/Util/RequestPropsExtractorTest.php

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

1212
namespace Symfony\UX\LiveComponent\Tests\Functional\Util;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\UX\LiveComponent\Metadata\LiveComponentMetadataFactory;
@@ -22,9 +23,7 @@ class RequestPropsExtractorTest extends KernelTestCase
2223
{
2324
use LiveComponentTestHelper;
2425

25-
/**
26-
* @dataProvider getQueryStringTests
27-
*/
26+
#[DataProvider('getQueryStringTests')]
2827
public function testExtractFromQueryString(string $queryString, array $expected, array $attributes = [])
2928
{
3029
$extractor = new RequestPropsExtractor($this->hydrator());
@@ -43,7 +42,7 @@ public function testExtractFromQueryString(string $queryString, array $expected,
4342
$this->assertEquals($expected, $data);
4443
}
4544

46-
public function getQueryStringTests(): iterable
45+
public static function getQueryStringTests(): iterable
4746
{
4847
yield from [
4948
'no query string' => ['', []],

src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php

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

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

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\Group;
1416
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1517
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1618
use Symfony\Component\Uid\Ulid;
@@ -153,10 +155,8 @@ private function executeHydrationTestCase(callable $testFactory, ?int $minPhpVer
153155
$this->assertEquals($componentAfterHydration, $hydratedComponent2, 'After another round of (de)hydration, things still match');
154156
}
155157

156-
/**
157-
* @group transient-on-windows
158-
* @dataProvider provideDehydrationHydrationTests
159-
*/
158+
#[Group('transient-on-windows')]
159+
#[DataProvider('provideDehydrationHydrationTests')]
160160
public function testCanDehydrateAndHydrateComponentWithTestCases(callable $testFactory, ?int $minPhpVersion = null)
161161
{
162162
$this->executeHydrationTestCase($testFactory, $minPhpVersion);
@@ -1636,9 +1636,7 @@ public function testInterfaceTypedLivePropCannotBeDehydrated()
16361636
$this->hydrator()->dehydrate($component, $this->createComponentAttributes(), $this->createLiveMetadata($component));
16371637
}
16381638

1639-
/**
1640-
* @dataProvider provideInvalidHydrationTests
1641-
*/
1639+
#[DataProvider('provideInvalidHydrationTests')]
16421640
public function testInvalidTypeHydration(callable $testFactory, ?int $minPhpVersion = null)
16431641
{
16441642
$this->executeHydrationTestCase($testFactory, $minPhpVersion);
@@ -1897,9 +1895,7 @@ public function testCanDehydrateAndHydrateComponentsWithEmptyAttributes()
18971895
$this->assertSame([], $actualAttributes->all());
18981896
}
18991897

1900-
/**
1901-
* @dataProvider truthyValueProvider
1902-
*/
1898+
#[DataProvider('truthyValueProvider')]
19031899
public function testCoerceTruthyValuesForScalarTypes($prop, $value, $expected)
19041900
{
19051901
$dehydratedProps = $this->dehydrateComponent($this->mountComponent('scalar_types'))->getProps();
@@ -1911,9 +1907,7 @@ public function testCoerceTruthyValuesForScalarTypes($prop, $value, $expected)
19111907
$this->assertSame($expected, $hydratedComponent->$prop);
19121908
}
19131909

1914-
/**
1915-
* @dataProvider falseyValueProvider
1916-
*/
1910+
#[DataProvider('falseyValueProvider')]
19171911
public function testCoerceFalseyValuesForScalarTypes($prop, $value, $expected)
19181912
{
19191913
$dehydratedProps = $this->dehydrateComponent($this->mountComponent('scalar_types'))->getProps();

src/LiveComponent/tests/Unit/EventListener/DeferLiveComponentSubscriberTest.php

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

1212
namespace Symfony\UX\LiveComponent\Tests\Unit\EventListener;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1616
use Symfony\UX\LiveComponent\EventListener\DeferLiveComponentSubscriber;
1717
use Symfony\UX\TwigComponent\ComponentMetadata;
1818
use Symfony\UX\TwigComponent\Event\PostMountEvent;
@@ -22,8 +22,6 @@
2222
*/
2323
class DeferLiveComponentSubscriberTest extends TestCase
2424
{
25-
use ExpectDeprecationTrait;
26-
2725
public function testLoadingAttributeIsExtracted()
2826
{
2927
$subscriber = new DeferLiveComponentSubscriber();
@@ -65,9 +63,7 @@ public function testLoadingAttributesAreRemoved()
6563
$this->assertArrayNotHasKey('loading-tag', $event->getData());
6664
}
6765

68-
/**
69-
* @dataProvider provideInvalidLoadingValues
70-
*/
66+
#[DataProvider('provideInvalidLoadingValues')]
7167
public function testInvalidLoadingValuesThrows(mixed $value)
7268
{
7369
$subscriber = new DeferLiveComponentSubscriber();

src/LiveComponent/tests/Unit/LiveCollectionTraitTest.php

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

1212
namespace Symfony\UX\LiveComponent\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\PropertyAccess\PropertyAccess;
@@ -21,7 +22,7 @@
2122
*/
2223
final class LiveCollectionTraitTest extends TestCase
2324
{
24-
/** @dataProvider provideAddedItems */
25+
#[DataProvider('provideAddedItems')]
2526
public function testAddCollectionItem(array $postedFormData, string $collectionFieldName, array $expectedFormData)
2627
{
2728
$component = $this->createComponent($postedFormData);
@@ -31,7 +32,7 @@ public function testAddCollectionItem(array $postedFormData, string $collectionF
3132
self::assertSame($expectedFormData[$component->formName], $component->formValues);
3233
}
3334

34-
/** @dataProvider provideRemovedItems */
35+
#[DataProvider('provideRemovedItems')]
3536
public function testRemoveCollectionItem(array $postedFormData, string $collectionFieldName, int $index, array $expectedFormData)
3637
{
3738
$component = $this->createComponent($postedFormData);

0 commit comments

Comments
 (0)