Skip to content

run tests with PHPUnit 12.0 on PHP >= 8.3 #61325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
exit(1);
}
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=11.5');
if (\PHP_VERSION_ID >= 80300) {
putenv('SYMFONY_PHPUNIT_VERSION=12.0');
} else {
putenv('SYMFONY_PHPUNIT_VERSION=11.5');
}
}
if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=deprecations=1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testPostGenerateSchema()
$dbalAdapter = $this->createMock(DoctrineDbalAdapter::class);
$dbalAdapter->expects($this->once())
->method('configureSchema')
->with($schema, $dbalConnection, fn () => true);
->with($schema, $dbalConnection, $this->callback(fn () => true));

$subscriber = new DoctrineDbalCacheAdapterSchemaListener([$dbalAdapter]);
$subscriber->postGenerateSchema($event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testPostGenerateSchemaLockPdo()
$lockStore = $this->createMock(DoctrineDbalStore::class);
$lockStore->expects($this->once())
->method('configureSchema')
->with($schema, fn () => true);
->with($schema, $this->callback(fn () => true));

$subscriber = new LockStoreSchemaListener((static fn () => yield $lockStore)());
$subscriber->postGenerateSchema($event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testPostGenerateSchema()
$doctrineTransport = $this->createMock(DoctrineTransport::class);
$doctrineTransport->expects($this->once())
->method('configureSchema')
->with($schema, $dbalConnection, fn () => true);
->with($schema, $dbalConnection, $this->callback(fn () => true));
$otherTransport = $this->createMock(TransportInterface::class);
$otherTransport->expects($this->never())
->method($this->anything());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testPostGenerateSchemaPdo()
$pdoSessionHandler = $this->createMock(PdoSessionHandler::class);
$pdoSessionHandler->expects($this->once())
->method('configureSchema')
->with($schema, fn () => true);
->with($schema, $this->callback(fn () => true));

$subscriber = new PdoSessionHandlerSchemaListener($pdoSessionHandler);
$subscriber->postGenerateSchema($event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,6 @@ public function testNamedClosures()
$this->assertNotSame($callback1, $callback2);
$this->assertNotSame($callback1, $callback3);
$this->assertNotSame($callback2, $callback3);
$this->assertEquals($callback1, $callback2);
$this->assertEquals($callback1, $callback3);

$this->dispatcher->addListener('foo', $callback1, 3);
$this->dispatcher->addListener('foo', $callback2, 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Form\Tests\ChoiceList;

use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\LazyChoiceList;

trait ChoiceListAssertionTrait
{
private function assertEqualsArrayChoiceList(ArrayChoiceList $expected, $actual)
{
$this->assertInstanceOf(ArrayChoiceList::class, $actual);
$this->assertEquals($expected->getChoices(), $actual->getChoices());
$this->assertEquals($expected->getStructuredValues(), $actual->getStructuredValues());
$this->assertEquals($expected->getOriginalKeys(), $actual->getOriginalKeys());
}

private function assertEqualsLazyChoiceList(LazyChoiceList $expected, $actual)
{
$this->assertInstanceOf(LazyChoiceList::class, $actual);
$this->assertEquals($expected->getChoices(), $actual->getChoices());
$this->assertEquals($expected->getValues(), $actual->getValues());
$this->assertEquals($expected->getOriginalKeys(), $actual->getOriginalKeys());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
use Symfony\Component\Form\ChoiceList\Factory\Cache\ChoiceLoader;
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Tests\ChoiceList\ChoiceListAssertionTrait;
use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader;

class ChoiceLoaderTest extends TestCase
{
use ChoiceListAssertionTrait;

public function testSameFormTypeUseCachedLoader()
{
$choices = ['f' => 'foo', 'b' => 'bar', 'z' => 'baz'];
Expand All @@ -30,8 +33,8 @@ public function testSameFormTypeUseCachedLoader()
$loader1 = new ChoiceLoader($type, $decorated);
$loader2 = new ChoiceLoader($type, new ArrayChoiceLoader());

$this->assertEquals($choiceList, $loader1->loadChoiceList());
$this->assertEquals($choiceList, $loader2->loadChoiceList());
$this->assertEqualsArrayChoiceList($choiceList, $loader1->loadChoiceList());
$this->assertEqualsArrayChoiceList($choiceList, $loader2->loadChoiceList());

$this->assertSame($choices, $loader1->loadChoicesForValues($choices));
$this->assertSame($choices, $loader2->loadChoicesForValues($choices));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
use Symfony\Component\Form\ChoiceList\Loader\FilterChoiceLoaderDecorator;
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Tests\ChoiceList\ChoiceListAssertionTrait;
use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class CachingFactoryDecoratorTest extends TestCase
{
use ChoiceListAssertionTrait;

private CachingFactoryDecorator $factory;

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

$this->assertSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList([]), $list1);
$this->assertEquals(new ArrayChoiceList([]), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList([]), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList([]), $list2);
}

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

$this->assertSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list1);
$this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['A' => 'a']), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['A' => 'a']), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList(['key' => ['A' => 'a']]), $list1);
$this->assertEquals(new ArrayChoiceList(['A' => 'a']), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['key' => ['A' => 'a']]), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList(['A' => 'a']), $list2);
}

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

$this->assertSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList([$choice1]), $list1);
$this->assertEquals(new ArrayChoiceList([$choice2]), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice1]), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice2]), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList([$choice1]), $list1);
$this->assertEquals(new ArrayChoiceList([$choice2]), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice1]), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList([$choice2]), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList($choices, $closure), $list1);
$this->assertEquals(new ArrayChoiceList($choices, $closure), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure), $list2);
}

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

$this->assertSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList($choices, $valueCallback), $list1);
$this->assertEquals(new ArrayChoiceList($choices, function () {}), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $valueCallback), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, function () {}), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new ArrayChoiceList($choices, $closure1), $list1);
$this->assertEquals(new ArrayChoiceList($choices, $closure2), $list2);
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure1), $list1);
self::assertEqualsArrayChoiceList(new ArrayChoiceList($choices, $closure2), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals($lazyChoiceList, $list1);
$this->assertEquals($lazyChoiceList, $list2);
self::assertEqualsLazyChoiceList($lazyChoiceList, $list1);
self::assertEqualsLazyChoiceList($lazyChoiceList, $list2);
}

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

$this->assertSame($list1, $list2);
$this->assertEquals($lazyChoiceList, $list1);
$this->assertEquals($lazyChoiceList, $list2);
self::assertEqualsLazyChoiceList($lazyChoiceList, $list1);
self::assertEqualsLazyChoiceList($lazyChoiceList, $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals($lazyChoiceList, $list1);
$this->assertEquals($lazyChoiceList, $list2);
self::assertEqualsLazyChoiceList($lazyChoiceList, $list1);
self::assertEqualsLazyChoiceList($lazyChoiceList, $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new LazyChoiceList($loader), $list1);
$this->assertEquals(new LazyChoiceList($loader), $list2);
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader), $list1);
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader), $list2);
}

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

$this->assertSame($list1, $list2);
$this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), null), $list1);
$this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), null), $list2);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new ArrayChoiceLoader(), null), $list1);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new ArrayChoiceLoader(), null), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new LazyChoiceList($loader, $closure), $list1);
$this->assertEquals(new LazyChoiceList($loader, $closure), $list2);
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader, $closure), $list1);
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader, $closure), $list2);
}

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

$this->assertSame($list1, $list2);
$this->assertEquals(new LazyChoiceList($loader, $closure), $list1);
$this->assertEquals(new LazyChoiceList(new ArrayChoiceLoader(), function () {}), $list2);
self::assertEqualsLazyChoiceList(new LazyChoiceList($loader, $closure), $list1);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new ArrayChoiceLoader(), function () {}), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator($loader, $closure)), $list1);
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure)), $list2);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator($loader, $closure)), $list1);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure)), $list2);
}

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

$this->assertSame($list1, $list2);
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list1);
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list2);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list1);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), function () {})), $list2);
}

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

$this->assertNotSame($list1, $list2);
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure1), null), $list1);
$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure2), null), $list2);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure1), null), $list1);
self::assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $closure2), null), $list2);
}

public function testCreateViewSamePreferredChoices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Tests\ChoiceList\ChoiceListAssertionTrait;
use Symfony\Component\Form\Tests\Fixtures\ArrayChoiceLoader;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class DefaultChoiceListFactoryTest extends TestCase
{
use ChoiceListAssertionTrait;

private \stdClass $obj1;
private \stdClass $obj2;
private \stdClass $obj3;
Expand Down Expand Up @@ -261,7 +264,7 @@ public function testCreateFromLoaderWithFilter()

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

$this->assertEquals(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $filter)), $list);
$this->assertEqualsLazyChoiceList(new LazyChoiceList(new FilterChoiceLoaderDecorator(new ArrayChoiceLoader(), $filter)), $list);
}

public function testCreateViewFlat()
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy