Skip to content

Commit 78bf2f3

Browse files
committed
run tests with PHPUnit 12.0 on PHP >= 8.3
1 parent aafbe05 commit 78bf2f3

File tree

17 files changed

+138
-73
lines changed

17 files changed

+138
-73
lines changed

phpunit

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
66
exit(1);
77
}
88
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
9-
putenv('SYMFONY_PHPUNIT_VERSION=11.5');
9+
if (\PHP_VERSION_ID >= 80300) {
10+
putenv('SYMFONY_PHPUNIT_VERSION=12.0');
11+
} else {
12+
putenv('SYMFONY_PHPUNIT_VERSION=11.5');
13+
}
1014
}
1115
if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
1216
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=deprecations=1');

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/DoctrineDbalCacheAdapterSchemaListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testPostGenerateSchema()
3535
$dbalAdapter = $this->createMock(DoctrineDbalAdapter::class);
3636
$dbalAdapter->expects($this->once())
3737
->method('configureSchema')
38-
->with($schema, $dbalConnection, fn () => true);
38+
->with($schema, $dbalConnection, $this->callback(fn () => true));
3939

4040
$subscriber = new DoctrineDbalCacheAdapterSchemaListener([$dbalAdapter]);
4141
$subscriber->postGenerateSchema($event);

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/LockStoreSchemaListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testPostGenerateSchemaLockPdo()
3434
$lockStore = $this->createMock(DoctrineDbalStore::class);
3535
$lockStore->expects($this->once())
3636
->method('configureSchema')
37-
->with($schema, fn () => true);
37+
->with($schema, $this->callback(fn () => true));
3838

3939
$subscriber = new LockStoreSchemaListener((static fn () => yield $lockStore)());
4040
$subscriber->postGenerateSchema($event);

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/MessengerTransportDoctrineSchemaListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testPostGenerateSchema()
3838
$doctrineTransport = $this->createMock(DoctrineTransport::class);
3939
$doctrineTransport->expects($this->once())
4040
->method('configureSchema')
41-
->with($schema, $dbalConnection, fn () => true);
41+
->with($schema, $dbalConnection, $this->callback(fn () => true));
4242
$otherTransport = $this->createMock(TransportInterface::class);
4343
$otherTransport->expects($this->never())
4444
->method($this->anything());

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/PdoSessionHandlerSchemaListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testPostGenerateSchemaPdo()
3434
$pdoSessionHandler = $this->createMock(PdoSessionHandler::class);
3535
$pdoSessionHandler->expects($this->once())
3636
->method('configureSchema')
37-
->with($schema, fn () => true);
37+
->with($schema, $this->callback(fn () => true));
3838

3939
$subscriber = new PdoSessionHandlerSchemaListener($pdoSessionHandler);
4040
$subscriber->postGenerateSchema($event);

src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ public function testNamedClosures()
411411
$this->assertNotSame($callback1, $callback2);
412412
$this->assertNotSame($callback1, $callback3);
413413
$this->assertNotSame($callback2, $callback3);
414-
$this->assertEquals($callback1, $callback2);
415-
$this->assertEquals($callback1, $callback3);
416414

417415
$this->dispatcher->addListener('foo', $callback1, 3);
418416
$this->dispatcher->addListener('foo', $callback2, 2);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Tests\ChoiceList;
13+
14+
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
15+
use Symfony\Component\Form\ChoiceList\LazyChoiceList;
16+
17+
trait ChoiceListAssertionTrait
18+
{
19+
private function assertEqualsArrayChoiceList(ArrayChoiceList $expected, $actual)
20+
{
21+
$this->assertInstanceOf(ArrayChoiceList::class, $actual);
22+
$this->assertEquals($expected->getChoices(), $actual->getChoices());
23+
$this->assertEquals($expected->getStructuredValues(), $actual->getStructuredValues());
24+
$this->assertEquals($expected->getOriginalKeys(), $actual->getOriginalKeys());
25+
}
26+
27+
private function assertEqualsLazyChoiceList(LazyChoiceList $expected, $actual)
28+
{
29+
$this->assertInstanceOf(LazyChoiceList::class, $actual);
30+
$this->assertEquals($expected->getChoices(), $actual->getChoices());
31+
$this->assertEquals($expected->getValues(), $actual->getValues());
32+
$this->assertEquals($expected->getOriginalKeys(), $actual->getOriginalKeys());
33+
}
34+
}

src/Symfony/Component/Form/Tests/ChoiceList/Factory/Cache/ChoiceLoaderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
use Symfony\Component\Form\ChoiceList\Factory\Cache\ChoiceLoader;
1717
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
1818
use Symfony\Component\Form\Extension\Core\Type\FormType;
19+
use Symfony\Component\Form\Tests\ChoiceList\ChoiceListAssertionTrait;
1920
use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader;
2021

2122
class ChoiceLoaderTest extends TestCase
2223
{
24+
use ChoiceListAssertionTrait;
25+
2326
public function testSameFormTypeUseCachedLoader()
2427
{
2528
$choices = ['f' => 'foo', 'b' => 'bar', 'z' => 'baz'];
@@ -30,8 +33,8 @@ public function testSameFormTypeUseCachedLoader()
3033
$loader1 = new ChoiceLoader($type, $decorated);
3134
$loader2 = new ChoiceLoader($type, new ArrayChoiceLoader());
3235

33-
$this->assertEquals($choiceList, $loader1->loadChoiceList());
34-
$this->assertEquals($choiceList, $loader2->loadChoiceList());
36+
$this->assertEqualsArrayChoiceList($choiceList, $loader1->loadChoiceList());
37+
$this->assertEqualsArrayChoiceList($choiceList, $loader2->loadChoiceList());
3538

3639
$this->assertSame($choices, $loader1->loadChoicesForValues($choices));
3740
$this->assertSame($choices, $loader2->loadChoicesForValues($choices));

src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
use Symfony\Component\Form\ChoiceList\Loader\FilterChoiceLoaderDecorator;
2323
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
2424
use Symfony\Component\Form\Extension\Core\Type\FormType;
25+
use Symfony\Component\Form\Tests\ChoiceList\ChoiceListAssertionTrait;
2526
use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader;
2627

2728
/**
2829
* @author Bernhard Schussek <bschussek@gmail.com>
2930
*/
3031
class CachingFactoryDecoratorTest extends TestCase
3132
{
33+
use ChoiceListAssertionTrait;
34+
3235
private CachingFactoryDecorator $factory;
3336

3437
protected function setUp(): void
@@ -42,8 +45,8 @@ public function testCreateFromChoicesEmpty()
4245
$list2 = $this->factory->createListFromChoices([]);
4346

4447
$this->assertSame($list1, $list2);
45-
$this->assertEquals(new ArrayChoiceList([]), $list1);
46-
$this->assertEquals(new ArrayChoiceList([]), $list2);
48+
self::assertEqualsArrayChoiceList(new ArrayChoiceList([]), $list1);
49+
self::assertEqualsArrayChoiceList(new ArrayChoiceList([]), $list2);
4750
}
4851

4952
public function testCreateFromChoicesComparesTraversableChoicesAsArray()
@@ -56,8 +59,8 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
5659
$list2 = $this->factory->createListFromChoices($choices2);
5760

5861
$this->assertSame($list1, $list2);
59-
$this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list1);
60-
$this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list2);
62+
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['A' => 'a']), $list1);
63+
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['A' => 'a']), $list2);
6164
}
6265

6366
public function testCreateFromChoicesGroupedChoices()
@@ -68,8 +71,8 @@ public function testCreateFromChoicesGroupedChoices()
6871
$list2 = $this->factory->createListFromChoices($choices2);
6972

7073
$this->assertNotSame($list1, $list2);
71-
$this->assertEquals(new ArrayChoiceList(['key' => ['A' => 'a']]), $list1);
72-
$this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list2);
74+
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['key' => ['A' => 'a']]), $list1);
75+
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['A' => 'a']), $list2);
7376
}
7477

7578
#[DataProvider('provideSameChoices')]
@@ -79,8 +82,8 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
7982
$list2 = $this->factory->createListFromChoices([$choice2]);
8083

8184
$this->assertSame($list1, $list2);
82-
$this->assertEquals(new ArrayChoiceList([$choice1]), $list1);
83-
$this->assertEquals(new ArrayChoiceList([$choice2]), $list2);
85+
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice1]), $list1);
86+
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice2]), $list2);
8487
}
8588

8689
#[DataProvider('provideDistinguishedChoices')]
@@ -90,8 +93,8 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
9093
$list2 = $this->factory->createListFromChoices([$choice2]);
9194

9295
$this->assertNotSame($list1, $list2);
93-
$this->assertEquals(new ArrayChoiceList([$choice1]), $list1);
94-
$this->assertEquals(new ArrayChoiceList([$choice2]), $list2);
96+
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice1]), $list1);
97+
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice2]), $list2);
9598
}
9699

97100
public function testCreateFromChoicesSameValueClosure()
@@ -103,8 +106,8 @@ public function testCreateFromChoicesSameValueClosure()
103106
$list2 = $this->factory->createListFromChoices($choices, $closure);
104107

105108
$this->assertNotSame($list1, $list2);
106-
$this->assertEquals(new ArrayChoiceList($choices, $closure), $list1);
107-
$this->assertEquals(new ArrayChoiceList($choices, $closure), $list2);
109+
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure), $list1);
110+
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure), $list2);
108111
}
109112

110113
public function testCreateFromChoicesSameValueClosureUseCache()
@@ -117,8 +120,8 @@ public function testCreateFromChoicesSameValueClosureUseCache()
117120
$list2 = $this->factory->createListFromChoices($choices, ChoiceList::value($formType, function () {}));
118121

119122
$this->assertSame($list1, $list2);
120-
$this->assertEquals(new ArrayChoiceList($choices, $valueCallback), $list1);
121-
$this->assertEquals(new ArrayChoiceList($choices, function () {}), $list2);
123+
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $valueCallback), $list1);
124+
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, function () {}), $list2);
122125
}
123126

124127
public function testCreateFromChoicesDifferentValueClosure()
@@ -130,8 +133,8 @@ public function testCreateFromChoicesDifferentValueClosure()
130133
$list2 = $this->factory->createListFromChoices($choices, $closure2);
131134

132135
$this->assertNotSame($list1, $list2);
133-
$this->assertEquals(new ArrayChoiceList($choices, $closure1), $list1);
134-
$this->assertEquals(new ArrayChoiceList($choices, $closure2), $list2);
136+
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure1), $list1);
137+
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure2), $list2);
135138
}
136139

137140
public function testCreateFromChoicesSameFilterClosure()
@@ -143,8 +146,8 @@ public function testCreateFromChoicesSameFilterClosure()
143146
$lazyChoiceList = new LazyChoiceList(new FilterChoiceLoaderDecorator(new CallbackChoiceLoader(static fn () => $choices), $filter), null);
144147

145148
$this->assertNotSame($list1, $list2);
146-
$this->assertEquals($lazyChoiceList, $list1);
147-
$this->assertEquals($lazyChoiceList, $list2);
149+
self::assertEqualsLazyChoiceList($lazyChoiceList, $list1);
150+
self::assertEqualsLazyChoiceList($lazyChoiceList, $list2);
148151
}
149152

150153
public function testCreateFromChoicesSameFilterClosureUseCache()
@@ -157,8 +160,8 @@ public function testCreateFromChoicesSameFilterClosureUseCache()
157160
$lazyChoiceList = new LazyChoiceList(new FilterChoiceLoaderDecorator(new CallbackChoiceLoader(static fn () => $choices), function () {}), null);
158161

159162
$this->assertSame($list1, $list2);
160-
$this->assertEquals($lazyChoiceList, $list1);
161-
$this->assertEquals($lazyChoiceList, $list2);
163+
self::assertEqualsLazyChoiceList($lazyChoiceList, $list1);
164+
self::assertEqualsLazyChoiceList($lazyChoiceList, $list2);
162165
}
163166

164167
public function testCreateFromChoicesDifferentFilterClosure()
@@ -171,8 +174,8 @@ public function testCreateFromChoicesDifferentFilterClosure()
171174
$lazyChoiceList = new LazyChoiceList(new FilterChoiceLoaderDecorator(new CallbackChoiceLoader(static fn () => $choices), function () {}), null);
172175

173176
$this->assertNotSame($list1, $list2);
174-
$this->assertEquals($lazyChoiceList, $list1);
175-
$this->assertEquals($lazyChoiceList, $list2);
177+
self::assertEqualsLazyChoiceList($lazyChoiceList, $list1);
178+
self::assertEqualsLazyChoiceList($lazyChoiceList, $list2);
176179
}
177180

178181
public function testCreateFromLoaderSameLoader()
@@ -182,8 +185,8 @@ public function testCreateFromLoaderSameLoader()
182185
$list2 = $this->factory->createListFromLoader($loader);
183186

184187
$this->assertNotSame($list1, $list2);
185-
$this->assertEquals(new LazyChoiceList($loader), $list1);
186-
$this->assertEquals(new LazyChoiceList($loader), $list2);
188+
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader), $list1);
189+
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader), $list2);
187190
}
188191

189192
public function testCreateFromLoaderSameLoaderUseCache()
@@ -193,8 +196,8 @@ public function testCreateFromLoaderSameLoaderUseCache()
193196
$list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()));
194197

195198
$this->assertSame($list1, $list2);
196-
$this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), null), $list1);
197-
$this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), null), $list2);
199+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new ArrayChoiceLoader(), null), $list1);
200+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new ArrayChoiceLoader(), null), $list2);
198201
}
199202

200203
public function testCreateFromLoaderDifferentLoader()
@@ -210,8 +213,8 @@ public function testCreateFromLoaderSameValueClosure()
210213
$list2 = $this->factory->createListFromLoader($loader, $closure);
211214

212215
$this->assertNotSame($list1, $list2);
213-
$this->assertEquals(new LazyChoiceList($loader, $closure), $list1);
214-
$this->assertEquals(new LazyChoiceList($loader, $closure), $list2);
216+
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader, $closure), $list1);
217+
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader, $closure), $list2);
215218
}
216219

217220
public function testCreateFromLoaderSameValueClosureUseCache()
@@ -223,8 +226,8 @@ public function testCreateFromLoaderSameValueClosureUseCache()
223226
$list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), ChoiceList::value($type, function () {}));
224227

225228
$this->assertSame($list1, $list2);
226-
$this->assertEquals(new LazyChoiceList($loader, $closure), $list1);
227-
$this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), function () {}), $list2);
229+
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader, $closure), $list1);
230+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new ArrayChoiceLoader(), function () {}), $list2);
228231
}
229232

230233
public function testCreateFromLoaderDifferentValueClosure()
@@ -246,8 +249,8 @@ public function testCreateFromLoaderSameFilterClosure()
246249
$list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $closure);
247250

248251
$this->assertNotSame($list1, $list2);
249-
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator($loader, $closure)), $list1);
250-
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure)), $list2);
252+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator($loader, $closure)), $list1);
253+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure)), $list2);
251254
}
252255

253256
public function testCreateFromLoaderSameFilterClosureUseCache()
@@ -258,8 +261,8 @@ public function testCreateFromLoaderSameFilterClosureUseCache()
258261
$list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $choiceFilter);
259262

260263
$this->assertSame($list1, $list2);
261-
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list1);
262-
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list2);
264+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list1);
265+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list2);
263266
}
264267

265268
public function testCreateFromLoaderDifferentFilterClosure()
@@ -271,8 +274,8 @@ public function testCreateFromLoaderDifferentFilterClosure()
271274
$list2 = $this->factory->createListFromLoader(ChoiceList::loader($type, new ArrayChoiceLoader()), null, $closure2);
272275

273276
$this->assertNotSame($list1, $list2);
274-
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure1), null), $list1);
275-
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure2), null), $list2);
277+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure1), null), $list1);
278+
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure2), null), $list2);
276279
}
277280

278281
public function testCreateViewSamePreferredChoices()

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
2121
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
2222
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
23+
use Symfony\Component\Form\Tests\ChoiceList\ChoiceListAssertionTrait;
2324
use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader;
2425
use Symfony\Component\Translation\TranslatableMessage;
2526
use Symfony\Contracts\Translation\TranslatableInterface;
2627
use Symfony\Contracts\Translation\TranslatorInterface;
2728

2829
class DefaultChoiceListFactoryTest extends TestCase
2930
{
31+
use ChoiceListAssertionTrait;
32+
3033
private \stdClass $obj1;
3134
private \stdClass $obj2;
3235
private \stdClass $obj3;
@@ -261,7 +264,7 @@ public function testCreateFromLoaderWithFilter()
261264

262265
$list = $this->factory->createListFromLoader(new ArrayChoiceLoader(), null, $filter);
263266

264-
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $filter)), $list);
267+
$this->assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $filter)), $list);
265268
}
266269

267270
public function testCreateViewFlat()

0 commit comments

Comments
 (0)