Skip to content

Commit b8a86cb

Browse files
committed
[Autocomplete][LiveComponent] Fix deprecations with zenstruck/foundry:^2.7
1 parent 6f7e617 commit b8a86cb

File tree

6 files changed

+49
-15
lines changed

6 files changed

+49
-15
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;
1313

1414
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\CategoryFixtureEntity;
15-
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
15+
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
1616

1717
/**
18-
* @extends PersistentProxyObjectFactory<CategoryFixtureEntity>
18+
* @extends PersistentObjectFactory<CategoryFixtureEntity>
1919
*/
20-
final class CategoryFixtureEntityFactory extends PersistentProxyObjectFactory
20+
final class CategoryFixtureEntityFactory extends PersistentObjectFactory
2121
{
2222
protected function defaults(): array|callable
2323
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;
1313

1414
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\CompositeIdEntity;
15-
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
15+
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
1616

1717
/**
18-
* @extends PersistentProxyObjectFactory<CompositeIdEntity>
18+
* @extends PersistentObjectFactory<CompositeIdEntity>
1919
*/
20-
class CompositeIdEntityFactory extends PersistentProxyObjectFactory
20+
class CompositeIdEntityFactory extends PersistentObjectFactory
2121
{
2222
public static function class(): string
2323
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\Entity1;
1515
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\ForeignKeyIdEntity;
16-
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
16+
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
1717

1818
use function Zenstruck\Foundry\lazy;
1919

2020
/**
21-
* @extends PersistentProxyObjectFactory<ForeignKeyIdEntity>
21+
* @extends PersistentObjectFactory<ForeignKeyIdEntity>
2222
*/
23-
class ForeignKeyIdEntityFactory extends PersistentProxyObjectFactory
23+
class ForeignKeyIdEntityFactory extends PersistentObjectFactory
2424
{
2525
public static function class(): string
2626
{
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\UX\LiveComponent\Tests\Fixtures\Factory;
13+
14+
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\ProductFixtureEntity;
15+
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
16+
17+
/**
18+
* @extends PersistentObjectFactory<ProductFixtureEntity>
19+
*/
20+
final class ProductFixtureEntityFactory extends PersistentObjectFactory
21+
{
22+
protected function defaults(): array|callable
23+
{
24+
return [
25+
'name' => self::faker()->name(),
26+
];
27+
}
28+
29+
public static function class(): string
30+
{
31+
return ProductFixtureEntity::class;
32+
}
33+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DoctrineEntityHydrationExtensionTest extends KernelTestCase
2727

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

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

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

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

src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use Symfony\UX\LiveComponent\Tests\Fixtures\Enum\IntEnum;
4545
use Symfony\UX\LiveComponent\Tests\Fixtures\Enum\StringEnum;
4646
use Symfony\UX\LiveComponent\Tests\Fixtures\Enum\ZeroIntEnum;
47+
use Symfony\UX\LiveComponent\Tests\Fixtures\Factory\ProductFixtureEntityFactory;
4748
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;
4849
use Symfony\UX\TwigComponent\ComponentAttributes;
4950
use Symfony\UX\TwigComponent\ComponentMetadata;
@@ -53,8 +54,8 @@
5354
use Zenstruck\Foundry\Test\ResetDatabase;
5455

5556
use function Zenstruck\Foundry\object;
57+
use function Zenstruck\Foundry\Persistence\delete;
5658
use function Zenstruck\Foundry\Persistence\persist;
57-
use function Zenstruck\Foundry\Persistence\proxy;
5859

5960
/**
6061
* @author Kevin Bond <[email protected]>
@@ -434,16 +435,16 @@ public function onEntireEntityUpdated($oldValue)
434435
}];
435436

436437
yield 'Persisted entity: deleting entity between dehydration and hydration sets it to null' => [function () {
437-
$product = proxy(persist(ProductFixtureEntity::class));
438+
$product = ProductFixtureEntityFactory::createOne();
438439

439440
return HydrationTest::create(new class {
440441
// test that event the writable path doesn't cause problems
441442
#[LiveProp(writable: ['name'])]
442443
public ?ProductFixtureEntity $product;
443444
})
444-
->mountWith(['product' => $product->_real()])
445+
->mountWith(['product' => $product])
445446
->beforeHydration(function () use ($product) {
446-
$product->_delete();
447+
delete($product);
447448
})
448449
->assertObjectAfterHydration(function (object $object) {
449450
self::assertNull(

0 commit comments

Comments
 (0)