@@ -29,7 +29,7 @@ class TypeFactoryTest extends TestCase
29
29
public function testGetType (array $ schema , Type $ type ): void
30
30
{
31
31
$ typeFactory = new TypeFactory ();
32
- $ this ->assertEquals ($ schema , $ typeFactory ->getType ($ type ));
32
+ $ this ->assertEquals ($ schema , $ typeFactory ->getType ($ type, ' json ' , null , null , new Schema () ));
33
33
}
34
34
35
35
public function typeProvider (): iterable
@@ -47,8 +47,8 @@ public function typeProvider(): iterable
47
47
yield [['type ' => 'string ' , 'format ' => 'date-time ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , \DateTimeImmutable::class)];
48
48
yield [['nullable ' => true , 'type ' => 'string ' , 'format ' => 'date-time ' ], new Type (Type::BUILTIN_TYPE_OBJECT , true , \DateTimeImmutable::class)];
49
49
yield [['type ' => 'string ' , 'format ' => 'duration ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , \DateInterval::class)];
50
- yield [['type ' => 'string ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , Dummy::class)];
51
- yield [['nullable ' => true , 'type ' => 'string ' ], new Type (Type::BUILTIN_TYPE_OBJECT , true , Dummy::class)];
50
+ yield [['type ' => 'string ' , ' format ' => ' iri-reference ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , Dummy::class)];
51
+ yield [['nullable ' => true , 'type ' => 'string ' , ' format ' => ' iri-reference ' ], new Type (Type::BUILTIN_TYPE_OBJECT , true , Dummy::class)];
52
52
yield [['type ' => 'array ' , 'items ' => ['type ' => 'string ' ]], new Type (Type::BUILTIN_TYPE_STRING , false , null , true )];
53
53
yield 'array can be itself nullable ' => [
54
54
['nullable ' => true , 'type ' => 'array ' , 'items ' => ['type ' => 'string ' ]],
@@ -147,7 +147,7 @@ public function typeProvider(): iterable
147
147
public function testGetTypeWithOpenAPIV2Syntax (array $ schema , Type $ type ): void
148
148
{
149
149
$ typeFactory = new TypeFactory ();
150
- $ this ->assertSame ($ schema , $ typeFactory ->getType ($ type , 'json ' , null , [TypeFactory:: CONTEXT_SERIALIZATION_FORMAT_OPENAPI_PRE_V3_0 => null ] ));
150
+ $ this ->assertSame ($ schema , $ typeFactory ->getType ($ type , 'json ' , null , null , new Schema (Schema:: VERSION_SWAGGER ) ));
151
151
}
152
152
153
153
public function openAPIV2typeProvider (): iterable
@@ -165,8 +165,8 @@ public function openAPIV2typeProvider(): iterable
165
165
yield [['type ' => 'string ' , 'format ' => 'date-time ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , \DateTimeImmutable::class)];
166
166
yield [['type ' => 'string ' , 'format ' => 'date-time ' ], new Type (Type::BUILTIN_TYPE_OBJECT , true , \DateTimeImmutable::class)];
167
167
yield [['type ' => 'string ' , 'format ' => 'duration ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , \DateInterval::class)];
168
- yield [['type ' => 'string ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , Dummy::class)];
169
- yield [['type ' => 'string ' ], new Type (Type::BUILTIN_TYPE_OBJECT , true , Dummy::class)];
168
+ yield [['type ' => 'string ' , ' format ' => ' iri-reference ' ], new Type (Type::BUILTIN_TYPE_OBJECT , false , Dummy::class)];
169
+ yield [['type ' => 'string ' , ' format ' => ' iri-reference ' ], new Type (Type::BUILTIN_TYPE_OBJECT , true , Dummy::class)];
170
170
yield [['type ' => 'array ' , 'items ' => ['type ' => 'string ' ]], new Type (Type::BUILTIN_TYPE_STRING , false , null , true )];
171
171
yield 'array can be itself nullable, but ignored in OpenAPI V2 ' => [
172
172
['type ' => 'array ' , 'items ' => ['type ' => 'string ' ]],
@@ -284,20 +284,11 @@ public function testGetClassTypeWithNullability(): void
284
284
$ typeFactory = new TypeFactory ();
285
285
$ typeFactory ->setSchemaFactory ($ schemaFactory );
286
286
287
- self ::assertSame (
288
- [
289
- 'nullable ' => true ,
290
- 'anyOf ' => [
291
- ['$ref ' => 'the-ref-name ' ],
292
- ],
287
+ self ::assertSame ([
288
+ 'nullable ' => true ,
289
+ 'anyOf ' => [
290
+ ['$ref ' => 'the-ref-name ' ],
293
291
],
294
- $ typeFactory ->getType (
295
- new Type (Type::BUILTIN_TYPE_OBJECT , true , Dummy::class),
296
- 'jsonld ' ,
297
- true ,
298
- ['foo ' => 'bar ' ],
299
- new Schema ()
300
- )
301
- );
292
+ ], $ typeFactory ->getType (new Type (Type::BUILTIN_TYPE_OBJECT , true , Dummy::class), 'jsonld ' , true , ['foo ' => 'bar ' ], new Schema ()));
302
293
}
303
294
}
0 commit comments