2222
2323 $ invalidRecords = [
2424 ['id ' => 10 , 'status ' => 'active ' ],
25- ['id ' => -5 , 'status ' => 'pending ' ], // -5 violates LocalId (positive-int)
25+ ['id ' => -5 , 'status ' => 'pending ' ],
2626 ];
2727
2828 expect (fn () => $ service ->saveLocalRecords ($ invalidRecords ))
29- ->toThrow (TypeError::class, "['id'] must be of type positive-int " )
30- ;
29+ ->toThrow (TypeError::class, "['id'] must be of type positive-int " );
3130 });
3231
3332 test ('throws TypeError when nested shape item violates local union alias ' , function () {
3433 $ service = new NestedAliasService ();
3534
3635 $ invalidRecords = [
37- ['id ' => 10 , 'status ' => 'archived ' ], // 'archived' violates LocalStatus ('active'|'pending')
36+ ['id ' => 10 , 'status ' => 'archived ' ],
3837 ];
3938
4039 expect (fn () => $ service ->saveLocalRecords ($ invalidRecords ))
41- ->toThrow (TypeError::class, "['status'] must be of type ('active' | 'pending') " )
42- ;
40+ ->toThrow (TypeError::class, "['status'] must be of type ('active' | 'pending') " );
4341 });
4442 });
4543
5957 $ service = new NestedAliasService ();
6058
6159 $ invalidRecords = [
62- ['id ' => -100 , 'status ' => 'active ' ],
60+ ['id ' => -100 , 'status ' => 'active ' ],
6361 ];
6462
6563 expect (fn () => $ service ->saveImportedRecords ($ invalidRecords ))
66- ->toThrow (TypeError::class, "['id'] must be of type positive-int " )
67- ;
64+ ->toThrow (TypeError::class, "['id'] must be of type positive-int " );
6865 });
6966
7067 test ('throws TypeError when nested shape item violates imported union alias ' , function () {
7572 ];
7673
7774 expect (fn () => $ service ->saveImportedRecords ($ invalidRecords ))
78- ->toThrow (TypeError::class, "['status'] must be of type ('active' | 'pending') " )
79- ;
75+ ->toThrow (TypeError::class, "['status'] must be of type ('active' | 'pending') " );
8076 });
8177 });
8278
8783 expect ($ service ->saveChainedData (['code ' => 50 , 'label ' => 'valid ' ]))->toBeTrue ();
8884
8985 expect (fn () => $ service ->saveChainedData (['code ' => -10 , 'label ' => 'valid ' ]))
90- ->toThrow (TypeError::class, "['code'] must be of type positive-int " )
91- ;
86+ ->toThrow (TypeError::class, "['code'] must be of type positive-int " );
9287
9388 expect (fn () => $ service ->saveChainedData (['code ' => 50 , 'label ' => '' ]))
94- ->toThrow (TypeError::class, "['label'] must be of type non-empty-string " )
95- ;
89+ ->toThrow (TypeError::class, "['label'] must be of type non-empty-string " );
9690 });
9791 });
9892
10498 expect ($ service ->setUnionStatus ('user_active ' ))->toBeTrue ();
10599
106100 expect (fn () => $ service ->setUnionStatus ('guest_active ' ))
107- ->toThrow (TypeError::class, "('admin_active' | 'user_active') " )
108- ;
101+ ->toThrow (TypeError::class, "('admin_active' | 'user_active') " );
109102 });
110103 });
111-
112- describe ('Edge Case 3: Property Hooks with Imported Type Aliases ' , function () {
113- test ('validates PHP 8.4 property hook write against imported 3-tier shape alias ' , function () {
114- $ service = new NestedAliasService ();
115-
116- $ service ->chainedProperty = ['code ' => 100 , 'label ' => 'updated ' ];
117- expect ($ service ->chainedProperty ['code ' ])->toBe (100 );
118-
119- expect (fn () => $ service ->chainedProperty = ['code ' => -1 , 'label ' => 'updated ' ])
120- ->toThrow (TypeError::class, "Property TypePHP\Tests\Fixtures\Types\NestedAliasService:: \$chainedProperty['code'] must be of type positive-int " );
121- });
122- });
123- });
104+ });
0 commit comments