Skip to content

Commit 8d8af6b

Browse files
committed
add failing test demonstrating bug
1 parent a33303d commit 8d8af6b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\UX\LiveComponent\Tests\Integration;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
15+
use Symfony\UX\LiveComponent\Attribute\LiveProp;
1516
use Symfony\UX\LiveComponent\LiveComponentHydrator;
1617
use Symfony\UX\LiveComponent\Tests\ContainerBC;
1718
use Symfony\UX\LiveComponent\Tests\Fixture\Component\Component1;
@@ -239,4 +240,29 @@ public function testCorrectlyUsesCustomFrontendNameInDehydrateAndHydrate(): void
239240
$this->assertSame('value1', $component->prop1);
240241
$this->assertSame('value2', $component->prop2);
241242
}
243+
244+
public function testCanDehydrateAndHydrateArrays(): void
245+
{
246+
/** @var LiveComponentHydrator $hydrator */
247+
$hydrator = self::getContainer()->get('ux.live_component.component_hydrator');
248+
249+
$component = new class() {
250+
#[LiveProp]
251+
public array $prop;
252+
};
253+
254+
$instance = clone $component;
255+
$instance->prop = ['some', 'array'];
256+
257+
$dehydrated = $hydrator->dehydrate($instance);
258+
259+
$this->assertArrayHasKey('prop', $dehydrated);
260+
$this->assertSame($instance->prop, $dehydrated['prop']);
261+
262+
$this->assertFalse(isset($component->prop));
263+
264+
$hydrator->hydrate($component, $dehydrated);
265+
266+
$this->assertSame($instance->prop, $component->prop);
267+
}
242268
}

0 commit comments

Comments
 (0)