Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;

use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\CategoryFixtureEntity;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

/**
* @extends PersistentProxyObjectFactory<CategoryFixtureEntity>
* @extends PersistentObjectFactory<CategoryFixtureEntity>
*/
final class CategoryFixtureEntityFactory extends PersistentProxyObjectFactory
final class CategoryFixtureEntityFactory extends PersistentObjectFactory
{
protected function defaults(): array|callable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;

use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\CompositeIdEntity;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

/**
* @extends PersistentProxyObjectFactory<CompositeIdEntity>
* @extends PersistentObjectFactory<CompositeIdEntity>
*/
class CompositeIdEntityFactory extends PersistentProxyObjectFactory
class CompositeIdEntityFactory extends PersistentObjectFactory
{
public static function class(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\Entity1;
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\ForeignKeyIdEntity;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

use function Zenstruck\Foundry\lazy;

/**
* @extends PersistentProxyObjectFactory<ForeignKeyIdEntity>
* @extends PersistentObjectFactory<ForeignKeyIdEntity>
*/
class ForeignKeyIdEntityFactory extends PersistentProxyObjectFactory
class ForeignKeyIdEntityFactory extends PersistentObjectFactory
{
public static function class(): string
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

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

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

use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\ProductFixtureEntity;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;

/**
* @extends PersistentObjectFactory<ProductFixtureEntity>
*/
final class ProductFixtureEntityFactory extends PersistentObjectFactory
{
protected function defaults(): array|callable
{
return [
'name' => self::faker()->name(),
];
}

public static function class(): string
{
return ProductFixtureEntity::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DoctrineEntityHydrationExtensionTest extends KernelTestCase

public function testCompositeId()
{
$compositeIdEntity = CompositeIdEntityFactory::createOne()->_real();
$compositeIdEntity = CompositeIdEntityFactory::createOne();

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

public function testForeignKeyId()
{
$foreignKeyIdEntity = ForeignKeyIdEntityFactory::createOne()->_real();
$foreignKeyIdEntity = ForeignKeyIdEntityFactory::createOne();

/** @var DoctrineEntityHydrationExtension $extension */
$extension = self::getContainer()->get('ux.live_component.doctrine_entity_hydration_extension');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Symfony\UX\LiveComponent\Tests\Fixtures\Enum\IntEnum;
use Symfony\UX\LiveComponent\Tests\Fixtures\Enum\StringEnum;
use Symfony\UX\LiveComponent\Tests\Fixtures\Enum\ZeroIntEnum;
use Symfony\UX\LiveComponent\Tests\Fixtures\Factory\ProductFixtureEntityFactory;
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;
use Symfony\UX\TwigComponent\ComponentAttributes;
use Symfony\UX\TwigComponent\ComponentMetadata;
Expand All @@ -53,8 +54,8 @@
use Zenstruck\Foundry\Test\ResetDatabase;

use function Zenstruck\Foundry\object;
use function Zenstruck\Foundry\Persistence\delete;
use function Zenstruck\Foundry\Persistence\persist;
use function Zenstruck\Foundry\Persistence\proxy;

/**
* @author Kevin Bond <[email protected]>
Expand Down Expand Up @@ -434,16 +435,16 @@ public function onEntireEntityUpdated($oldValue)
}];

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

return HydrationTest::create(new class {
// test that event the writable path doesn't cause problems
#[LiveProp(writable: ['name'])]
public ?ProductFixtureEntity $product;
})
->mountWith(['product' => $product->_real()])
->mountWith(['product' => $product])
->beforeHydration(function () use ($product) {
$product->_delete();
delete($product);
})
->assertObjectAfterHydration(function (object $object) {
self::assertNull(
Expand Down
Loading