Skip to content

Commit c139beb

Browse files
committed
Update Foundry and fix (almost all) deprecations
1 parent 09bbd68 commit c139beb

File tree

10 files changed

+138
-136
lines changed

10 files changed

+138
-136
lines changed

src/LiveComponent/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
5252
"symfony/validator": "^5.4|^6.0|^7.0",
5353
"zenstruck/browser": "^1.2.0",
54-
"zenstruck/foundry": "1.37.*"
54+
"zenstruck/foundry": "^2.0"
5555
},
5656
"conflict": {
5757
"symfony/config": "<5.4.0"

src/LiveComponent/phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
<server name="KERNEL_CLASS" value="Symfony\UX\LiveComponent\Tests\Fixtures\Kernel"/>
1919
<server name="DATABASE_URL" value="sqlite:///%kernel.project_dir%/var/data.db"/>
2020
<env name="SHELL_VERBOSITY" value="-1"/>
21-
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;ignoreFile=./tests/baseline-ignore"/>
21+
<!-- <server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;ignoreFile=./tests/baseline-ignore"/>-->
22+
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;quiet[]=indirect&amp;quiet[]=other"/>
2223
</php>
2324

2425
<testsuites>

src/LiveComponent/tests/Fixtures/Dto/HoldsArrayOfDtos.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Symfony package.
7+
*
8+
* (c) Fabien Potencier <fabien@symfony.com>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Dto;
615

716
final class HoldsArrayOfDtos
817
{
918
/**
10-
* @var Address[] $addresses
19+
* @var Address[]
1120
*/
1221
public array $addresses;
1322
}

src/LiveComponent/tests/Fixtures/Factory/CompositeIdEntityFactory.php

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,39 @@
1111

1212
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;
1313

14-
use Doctrine\ORM\EntityRepository;
1514
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\CompositeIdEntity;
16-
use Zenstruck\Foundry\ModelFactory;
17-
use Zenstruck\Foundry\Proxy;
18-
use Zenstruck\Foundry\RepositoryProxy;
15+
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
16+
use Zenstruck\Foundry\Persistence\Proxy;
1917

2018
/**
21-
* @extends ModelFactory<CompositeIdEntity>
19+
* @extends PersistentProxyObjectFactory<CompositeIdEntity>
2220
*
23-
* @method static CompositeIdEntity|Proxy createOne(array $attributes = [])
24-
* @method static CompositeIdEntity[]|Proxy[] createMany(int $number, array|callable $attributes = [])
25-
* @method static CompositeIdEntity|Proxy find(object|array|mixed $criteria)
26-
* @method static CompositeIdEntity|Proxy findOrCreate(array $attributes)
27-
* @method static CompositeIdEntity|Proxy first(string $sortedField = 'id')
28-
* @method static CompositeIdEntity|Proxy last(string $sortedField = 'id')
29-
* @method static CompositeIdEntity|Proxy random(array $attributes = [])
30-
* @method static CompositeIdEntity|Proxy randomOrCreate(array $attributes = []))
31-
* @method static CompositeIdEntity[]|Proxy[] all()
32-
* @method static CompositeIdEntity[]|Proxy[] findBy(array $attributes)
33-
* @method static CompositeIdEntity[]|Proxy[] randomSet(int $number, array $attributes = []))
34-
* @method static CompositeIdEntity[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
35-
* @method static EntityRepository|RepositoryProxy repository()
36-
* @method CompositeIdEntity|Proxy create(array|callable $attributes = [])
21+
* @method static CompositeIdEntity|Proxy createOne(array $attributes = [])
22+
* @method static CompositeIdEntity[]|Proxy[] createMany(int $number, array|callable $attributes = [])
23+
* @method static CompositeIdEntity|Proxy find(object|array|mixed $criteria)
24+
* @method static CompositeIdEntity|Proxy findOrCreate(array $attributes)
25+
* @method static CompositeIdEntity|Proxy first(string $sortedField = 'id')
26+
* @method static CompositeIdEntity|Proxy last(string $sortedField = 'id')
27+
* @method static CompositeIdEntity|Proxy random(array $attributes = [])
28+
* @method static CompositeIdEntity|Proxy randomOrCreate(array $attributes = []))
29+
* @method static CompositeIdEntity[]|Proxy[] all()
30+
* @method static CompositeIdEntity[]|Proxy[] findBy(array $attributes)
31+
* @method static CompositeIdEntity[]|Proxy[] randomSet(int $number, array $attributes = []))
32+
* @method static CompositeIdEntity[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
33+
* @method CompositeIdEntity|Proxy create(array|callable $attributes = [])
3734
*/
38-
class CompositeIdEntityFactory extends ModelFactory
35+
class CompositeIdEntityFactory extends PersistentProxyObjectFactory
3936
{
40-
protected static function getClass(): string
41-
{
42-
return CompositeIdEntity::class;
43-
}
44-
45-
protected function getDefaults(): array
37+
protected function defaults(): array|callable
4638
{
4739
return [
4840
'firstIdPart' => rand(1, \PHP_INT_MAX),
4941
'secondIdPart' => rand(1, \PHP_INT_MAX),
5042
];
5143
}
44+
45+
public static function class(): string
46+
{
47+
return CompositeIdEntity::class;
48+
}
5249
}

src/LiveComponent/tests/Fixtures/Factory/ForeignKeyIdEntityFactory.php

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,38 @@
1111

1212
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;
1313

14-
use Doctrine\ORM\EntityRepository;
1514
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\Entity1;
1615
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\ForeignKeyIdEntity;
17-
use Zenstruck\Foundry\ModelFactory;
18-
use Zenstruck\Foundry\Proxy;
19-
use Zenstruck\Foundry\RepositoryProxy;
16+
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
2017

18+
use Zenstruck\Foundry\Persistence\Proxy;
2119
use function Zenstruck\Foundry\lazy;
2220

2321
/**
24-
* @extends ModelFactory<ForeignKeyIdEntity>
22+
* @extends PersistentProxyObjectFactory<ForeignKeyIdEntity>
2523
*
26-
* @method static ForeignKeyIdEntity|Proxy createOne(array $attributes = [])
27-
* @method static ForeignKeyIdEntity[]|Proxy[] createMany(int $number, array|callable $attributes = [])
28-
* @method static ForeignKeyIdEntity|Proxy find(object|array|mixed $criteria)
29-
* @method static ForeignKeyIdEntity|Proxy findOrCreate(array $attributes)
30-
* @method static ForeignKeyIdEntity|Proxy first(string $sortedField = 'id')
31-
* @method static ForeignKeyIdEntity|Proxy last(string $sortedField = 'id')
32-
* @method static ForeignKeyIdEntity|Proxy random(array $attributes = [])
33-
* @method static ForeignKeyIdEntity|Proxy randomOrCreate(array $attributes = []))
34-
* @method static ForeignKeyIdEntity[]|Proxy[] all()
35-
* @method static ForeignKeyIdEntity[]|Proxy[] findBy(array $attributes)
36-
* @method static ForeignKeyIdEntity[]|Proxy[] randomSet(int $number, array $attributes = []))
37-
* @method static ForeignKeyIdEntity[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
38-
* @method static EntityRepository|RepositoryProxy repository()
39-
* @method ForeignKeyIdEntity|Proxy create(array|callable $attributes = [])
24+
* @method static ForeignKeyIdEntity|Proxy createOne(array $attributes = [])
25+
* @method static ForeignKeyIdEntity[]|Proxy[] createMany(int $number, array|callable $attributes = [])
26+
* @method static ForeignKeyIdEntity|Proxy find(object|array|mixed $criteria)
27+
* @method static ForeignKeyIdEntity|Proxy findOrCreate(array $attributes)
28+
* @method static ForeignKeyIdEntity|Proxy first(string $sortedField = 'id')
29+
* @method static ForeignKeyIdEntity|Proxy last(string $sortedField = 'id')
30+
* @method static ForeignKeyIdEntity|Proxy random(array $attributes = [])
31+
* @method static ForeignKeyIdEntity|Proxy randomOrCreate(array $attributes = []))
32+
* @method static ForeignKeyIdEntity[]|Proxy[] all()
33+
* @method static ForeignKeyIdEntity[]|Proxy[] findBy(array $attributes)
34+
* @method static ForeignKeyIdEntity[]|Proxy[] randomSet(int $number, array $attributes = []))
35+
* @method static ForeignKeyIdEntity[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
4036
*/
41-
class ForeignKeyIdEntityFactory extends ModelFactory
37+
class ForeignKeyIdEntityFactory extends PersistentProxyObjectFactory
4238
{
43-
protected static function getClass(): string
39+
protected function defaults(): array|callable
4440
{
45-
return ForeignKeyIdEntity::class;
41+
return ['id' => lazy(static fn () => new Entity1())];
4642
}
4743

48-
protected function getDefaults(): array
44+
public static function class(): string
4945
{
50-
return ['id' => lazy(static fn () => new Entity1())];
46+
return ForeignKeyIdEntity::class;
5147
}
5248
}

src/LiveComponent/tests/Fixtures/Kernel.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,13 @@ protected function configureContainer(ContainerConfigurator $c): void
182182
$doctrineConfig['orm']['validate_xml_mapping'] = true;
183183
$doctrineConfig['dbal']['schema_manager_factory'] = 'doctrine.dbal.default_schema_manager_factory';
184184
}
185-
if (version_compare($doctrineBundleVersion, '2.12.0', '=')) {
186-
$doctrineConfig['orm']['controller_resolver']['auto_mapping'] = true;
185+
if (version_compare($doctrineBundleVersion, '2.12.0', '>=')) {
186+
$doctrineConfig['orm']['controller_resolver']['auto_mapping'] = false;
187187
}
188188
}
189189

190190
$c->extension('doctrine', $doctrineConfig);
191191

192-
$c->extension('zenstruck_foundry', [
193-
'auto_refresh_proxies' => false,
194-
]);
195-
196192
$c->services()
197193
->defaults()
198194
->autowire()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Zenstruck\Foundry\Test\Factories;
2323
use Zenstruck\Foundry\Test\ResetDatabase;
2424

25-
use function Zenstruck\Foundry\create;
25+
use function Zenstruck\Foundry\Persistence\persist;
2626

2727
/**
2828
* @author Kevin Bond <kevinbond@gmail.com>
@@ -48,7 +48,7 @@ final class LiveComponentSubscriberTest extends KernelTestCase
4848
public function testCanRenderComponentAsHtml(): void
4949
{
5050
$component = $this->mountComponent('component1', [
51-
'prop1' => $entity = create(Entity1::class)->object(),
51+
'prop1' => $entity = persist(Entity1::class),
5252
'prop2' => $date = new \DateTime('2021-03-05 9:23'),
5353
'prop3' => 'value3',
5454
'prop4' => 'value4',

src/LiveComponent/tests/Integration/Hydration/DoctrineEntityHydrationExtensionTest.php

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

12-
namespace Symfony\UX\LiveComponent\Tests\Unit\Hydration;
12+
namespace Symfony\UX\LiveComponent\Tests\Integration\Hydration;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1515
use Symfony\UX\LiveComponent\Hydration\DoctrineEntityHydrationExtension;
@@ -27,7 +27,7 @@ class DoctrineEntityHydrationExtensionTest extends KernelTestCase
2727

2828
public function testCompositeId(): void
2929
{
30-
$compositeIdEntity = CompositeIdEntityFactory::createOne()->save()->object();
30+
$compositeIdEntity = CompositeIdEntityFactory::createOne()->_real();
3131

3232
/** @var DoctrineEntityHydrationExtension $extension */
3333
$extension = self::getContainer()->get('ux.live_component.doctrine_entity_hydration_extension');
@@ -40,7 +40,7 @@ public function testCompositeId(): void
4040

4141
public function testForeignKeyId(): void
4242
{
43-
$foreignKeyIdEntity = ForeignKeyIdEntityFactory::createOne()->save()->object();
43+
$foreignKeyIdEntity = ForeignKeyIdEntityFactory::createOne()->_real();
4444

4545
/** @var DoctrineEntityHydrationExtension $extension */
4646
$extension = self::getContainer()->get('ux.live_component.doctrine_entity_hydration_extension');

0 commit comments

Comments
 (0)