44namespace EventEngineTest \JsonSchema ;
55
66use EventEngine \JsonSchema \JsonSchema ;
7- use EventEngine \JsonSchema \Type \TypeRef ;
87use EventEngineTest \JsonSchema \Stub \ArrayItemRecord ;
98use EventEngineTest \JsonSchema \Stub \CollectionItemAllowNestedRecord ;
109use EventEngineTest \JsonSchema \Stub \CollectionItemRecord ;
1312use EventEngineTest \JsonSchema \Stub \NullableScalarPropsRecord ;
1413use EventEngineTest \JsonSchema \Stub \ScalarPropsRecord ;
1514use EventEngineTest \JsonSchema \Stub \VoOptionalPropsRecord ;
15+ use EventEngineTest \JsonSchema \Stub \VoProp \UserId ;
1616use EventEngineTest \JsonSchema \Stub \VoPropsRecord ;
1717
1818final class JsonSchemaAwareRecordLogicTest extends BasicTestCase
@@ -100,7 +100,7 @@ public function it_uses_item_schema_from_collection()
100100 $ schema = CollectionItemRecord::__schema ();
101101
102102 $ expected = JsonSchema::object ([
103- 'friends ' => JsonSchema::array (JsonSchema::typeRef (ScalarPropsRecord::__type ()))
103+ 'friends ' => JsonSchema::array (JsonSchema::typeRef (ScalarPropsRecord::__type ()))-> withMaxItems ( 10 )
104104 ]);
105105
106106 $ this ->assertEquals ($ expected ->toArray (), $ schema ->toArray ());
@@ -127,10 +127,10 @@ public function it_detects_scalar_types_through_method_analysis_of_vo_classes()
127127 $ schema = VoPropsRecord::__schema ();
128128
129129 $ expected = JsonSchema::object ([
130- 'userId ' => JsonSchema::string (),
131- 'age ' => JsonSchema::integer (),
130+ 'userId ' => JsonSchema::string ()-> withPattern (UserId:: PATTERN ) ,
131+ 'age ' => JsonSchema::integer ()-> withRange ( 0 , 150 ) ,
132132 'member ' => JsonSchema::boolean (),
133- 'score ' => JsonSchema::float ()
133+ 'score ' => JsonSchema::float ()-> withRange ( 0.1 , 1 ),
134134 ]);
135135
136136 $ this ->assertEquals ($ expected ->toArray (), $ schema ->toArray ());
@@ -144,11 +144,11 @@ public function it_respects_optional_properties()
144144 $ schema = VoOptionalPropsRecord::__schema ();
145145
146146 $ expected = JsonSchema::object ([
147- 'userId ' => JsonSchema::string (),
148- 'age ' => JsonSchema::integer (),
147+ 'userId ' => JsonSchema::string ()-> withPattern (UserId:: PATTERN ) ,
148+ 'age ' => JsonSchema::integer ()-> withRange ( 0 , 150 ) ,
149149 'member ' => JsonSchema::boolean (),
150150 ], [
151- 'score ' => JsonSchema::float ()
151+ 'score ' => JsonSchema::float ()-> withRange ( 0.1 , 1 ),
152152 ]);
153153
154154 $ this ->assertEquals ($ expected ->toArray (), $ schema ->toArray ());
0 commit comments