Skip to content

Commit afef986

Browse files
committed
Add testObjectTypedLivePropCannotBeDehydrated and update CHANGELOG.md
1 parent 2da2c11 commit afef986

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/LiveComponent/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
- Add support for `LiveProp` union types in Live Components.
66
`LiveComponentMetadataFactory` can now create `liveProp` metadata for union types.
7-
Note: This feature only works when using a custom `hydrate` and `dehydrate` implementation.
87

98
## 2.31
109

src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,23 @@ public function testInterfaceTypedLivePropCannotBeDehydrated()
16361636
$this->hydrator()->dehydrate($component, $this->createComponentAttributes(), $this->createLiveMetadata($component));
16371637
}
16381638

1639+
public function testObjectTypedLivePropCannotBeDehydrated()
1640+
{
1641+
$componentClass = new class {
1642+
#[LiveProp(writable: true)]
1643+
public object $object;
1644+
};
1645+
1646+
$component = new $componentClass();
1647+
$component->object = new class {
1648+
};
1649+
1650+
$this->expectException(\LogicException::class);
1651+
$this->expectExceptionMessageMatches('/The "object" property on component ".*" is missing its property-type. Add the ".*" type so the object can be hydrated later./');
1652+
1653+
$this->hydrator()->dehydrate($component, $this->createComponentAttributes(), $this->createLiveMetadata($component));
1654+
}
1655+
16391656
/**
16401657
* @dataProvider provideInvalidHydrationTests
16411658
*/

0 commit comments

Comments
 (0)