@@ -1502,70 +1502,100 @@ public function __construct(
15021502 $ dataClass = new class () extends Data {
15031503 public InertiaDeferred |string $ deferred ;
15041504
1505+ public InertiaDeferred |string $ deferredWithGroup ;
1506+
15051507 public function __construct ()
15061508 {
15071509 }
15081510 };
15091511
15101512 $ data = $ dataClass ::from ([
15111513 "deferred " => Lazy::inertiaDeferred (Inertia::defer (fn () => 'Deferred Value ' )),
1514+ "deferredWithGroup " => Lazy::inertiaDeferred (Inertia::defer (fn () => 'Deferred Value ' , 'deferred-group ' )),
15121515 ]);
15131516
15141517 expect ($ data ->deferred )->toBeInstanceOf (InertiaDeferred::class);
15151518 expect ($ data ->all ()['deferred ' ])->toBeInstanceOf (DeferProp::class);
15161519 expect ($ data ->all ()['deferred ' ]())->toBe ('Deferred Value ' );
15171520
1521+ expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1522+ expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1523+ expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1524+ expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
15181525});
15191526
15201527it ('can create a data object with inertia deferred closure ' , function () {
15211528 $ dataClass = new class () extends Data {
15221529 public InertiaDeferred |string $ deferred ;
15231530
1531+ public InertiaDeferred |string $ deferredWithGroup ;
1532+
15241533 public function __construct ()
15251534 {
15261535 }
15271536 };
15281537
15291538 $ data = $ dataClass ::from ([
15301539 "deferred " => Lazy::inertiaDeferred (fn () => 'Deferred Value ' ),
1540+ "deferredWithGroup " => Lazy::inertiaDeferred (fn () => 'Deferred Value ' , 'deferred-group ' ),
15311541 ]);
15321542
15331543 expect ($ data ->deferred )->toBeInstanceOf (InertiaDeferred::class);
15341544 expect ($ data ->all ()['deferred ' ])->toBeInstanceOf (DeferProp::class);
15351545 expect ($ data ->all ()['deferred ' ]())->toBe ('Deferred Value ' );
15361546
1547+ expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1548+ expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1549+ expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1550+ expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
1551+
15371552});
15381553
15391554it ('can create a data object with inertia deferred value ' , function () {
15401555 $ dataClass = new class () extends Data {
15411556 public InertiaDeferred |string $ deferred ;
15421557
1558+ public InertiaDeferred |string $ deferredWithGroup ;
1559+
15431560 public function __construct ()
15441561 {
15451562 }
15461563 };
15471564
15481565 $ data = $ dataClass ::from ([
15491566 "deferred " => Lazy::inertiaDeferred ('Deferred Value ' ),
1567+ "deferredWithGroup " => Lazy::inertiaDeferred ('Deferred Value ' , 'deferred-group ' ),
15501568 ]);
15511569
15521570 expect ($ data ->deferred )->toBeInstanceOf (InertiaDeferred::class);
15531571 expect ($ data ->all ()['deferred ' ])->toBeInstanceOf (DeferProp::class);
15541572 expect ($ data ->all ()['deferred ' ]())->toBe ('Deferred Value ' );
15551573
1574+ expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1575+ expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1576+ expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1577+ expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
15561578});
15571579
15581580it ('can use auto deferred to construct a inertia deferred property ' , function () {
15591581 $ dataClass = new class () extends Data {
15601582 #[AutoInertiaDeferred]
15611583 public InertiaDeferred |string $ string ;
1584+
1585+ #[AutoInertiaDeferred('deferred-group ' )]
1586+ public InertiaDeferred |string $ deferredWithGroup ;
15621587 };
15631588
1564- $ data = $ dataClass ::from (['string ' => 'Deferred Value ' ]);
1589+ $ data = $ dataClass ::from (['string ' => 'Deferred Value ' , ' deferredWithGroup ' => ' Deferred Value ' ]);
15651590
15661591 expect ($ data ->string )->toBeInstanceOf (InertiaDeferred::class);
15671592 expect ($ data ->all ()['string ' ])->toBeInstanceOf (DeferProp::class);
15681593 expect ($ data ->all ()['string ' ]())->toBe ('Deferred Value ' );
1594+
1595+ expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1596+ expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1597+ expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1598+ expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
15691599});
15701600
15711601it ('can use class level auto deferred to construct a inertia deferred property ' , function () {
@@ -1575,128 +1605,13 @@ class AutoDeferredData extends Data
15751605 public InertiaDeferred |string $ string ;
15761606 }
15771607
1578- ;
1579-
15801608 $ data = AutoDeferredData::from (['string ' => 'Deferred Value ' ]);
15811609
15821610 expect ($ data ->string )->toBeInstanceOf (InertiaDeferred::class);
15831611 expect ($ data ->all ()['string ' ])->toBeInstanceOf (DeferProp::class);
15841612 expect ($ data ->all ()['string ' ]())->toBe ('Deferred Value ' );
15851613});
15861614
1587- it ('can create a data object with inertia deferred properties with a group as Inertia::defer argument ' , function () {
1588- $ dataClass = new class () extends Data {
1589- public InertiaDeferred |string $ deferredWithGroup ;
1590-
1591- public function __construct ()
1592- {
1593- }
1594- };
1595-
1596- $ data = $ dataClass ::from ([
1597- "deferredWithGroup " => Lazy::inertiaDeferred (Inertia::defer (fn () => 'Deferred Value ' , 'deferred-group ' )),
1598- ]);
1599-
1600- expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1601- expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1602- expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1603- expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
1604-
1605- });
1606-
1607- it ('can create a data object with inertia deferred properties with a group as Lazy::inertiaDeferred argument ' , function () {
1608- $ dataClass = new class () extends Data {
1609- public InertiaDeferred |string $ deferredWithGroup ;
1610-
1611- public function __construct ()
1612- {
1613- }
1614- };
1615-
1616- $ data = $ dataClass ::from ([
1617- "deferredWithGroup " => Lazy::inertiaDeferred (Inertia::defer (fn () => 'Deferred Value ' ), 'deferred-group ' ),
1618- ]);
1619-
1620- expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1621- expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1622- expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1623- expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
1624-
1625- });
1626-
1627- it ('can create a data object with inertia deferred closure with a group ' , function () {
1628- $ dataClass = new class () extends Data {
1629- public InertiaDeferred |string $ deferredWithGroup ;
1630-
1631- public function __construct ()
1632- {
1633- }
1634- };
1635-
1636- $ data = $ dataClass ::from ([
1637- "deferredWithGroup " => Lazy::inertiaDeferred (fn () => 'Deferred Value ' , 'deferred-group ' ),
1638- ]);
1639-
1640- expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1641- expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1642- expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1643- expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
1644-
1645- });
1646-
1647- it ('can create a data object with inertia deferred value with a group ' , function () {
1648- $ dataClass = new class () extends Data {
1649- public InertiaDeferred |string $ deferredWithGroup ;
1650-
1651- public function __construct ()
1652- {
1653- }
1654- };
1655-
1656- $ data = $ dataClass ::from ([
1657- "deferredWithGroup " => Lazy::inertiaDeferred ('Deferred Value ' , 'deferred-group ' ),
1658- ]);
1659-
1660- expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1661- expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1662- expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1663- expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
1664-
1665- });
1666-
1667- it ('can use auto deferred to construct a inertia deferred property with a group ' , function () {
1668- $ dataClass = new class () extends Data {
1669- #[AutoInertiaDeferred('deferred-group ' )]
1670- public InertiaDeferred |string $ deferredWithGroup ;
1671- };
1672-
1673- $ data = $ dataClass ::from (['deferredWithGroup ' => 'Deferred Value ' ]);
1674-
1675- expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1676- expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1677- expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1678- expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
1679-
1680- });
1681-
1682- it ('can use class level auto deferred to construct a inertia deferred property with a group ' , function () {
1683- #[AutoInertiaDeferred('deferred-group ' )]
1684- class AutoDeferredDataWithGroup extends Data
1685- {
1686- public InertiaDeferred |string $ deferredWithGroup ;
1687- }
1688-
1689- ;
1690-
1691- $ data = AutoDeferredDataWithGroup::from (['deferredWithGroup ' => 'Deferred Value ' ]);
1692-
1693- expect ($ data ->deferredWithGroup )->toBeInstanceOf (InertiaDeferred::class);
1694- expect ($ data ->all ()['deferredWithGroup ' ])->toBeInstanceOf (DeferProp::class);
1695- expect ($ data ->all ()['deferredWithGroup ' ]())->toBe ('Deferred Value ' );
1696- expect ($ data ->all ()['deferredWithGroup ' ]->group ())->toBe ('deferred-group ' );
1697-
1698- });
1699-
17001615describe ('property-morphable creation tests ' , function () {
17011616 enum TestPropertyMorphableEnum: string
17021617 {
0 commit comments