@@ -53,10 +53,11 @@ class OpenApiNormalizerTest extends TestCase
53
53
public function testNormalize ()
54
54
{
55
55
$ resourceNameCollectionFactoryProphecy = $ this ->prophesize (ResourceNameCollectionFactoryInterface::class);
56
- $ resourceNameCollectionFactoryProphecy ->create ()->shouldBeCalled ()->willReturn (new ResourceNameCollection ([Dummy::class]));
56
+ $ resourceNameCollectionFactoryProphecy ->create ()->shouldBeCalled ()->willReturn (new ResourceNameCollection ([Dummy::class, ' Zorro ' ]));
57
57
$ defaultContext = ['base_url ' => '/app_dev.php/ ' ];
58
58
$ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
59
59
$ propertyNameCollectionFactoryProphecy ->create (Dummy::class, Argument::any ())->shouldBeCalled ()->willReturn (new PropertyNameCollection (['id ' , 'name ' , 'description ' , 'dummyDate ' ]));
60
+ $ propertyNameCollectionFactoryProphecy ->create ('Zorro ' , Argument::any ())->shouldBeCalled ()->willReturn (new PropertyNameCollection (['id ' ]));
60
61
61
62
$ dummyMetadata = new ResourceMetadata (
62
63
'Dummy ' ,
@@ -74,18 +75,34 @@ public function testNormalize()
74
75
[]
75
76
);
76
77
78
+ $ zorroMetadata = new ResourceMetadata (
79
+ 'Zorro ' ,
80
+ 'This is zorro. ' ,
81
+ 'http://schema.example.com/Zorro ' ,
82
+ [
83
+ 'get ' => ['method ' => 'GET ' ] + self ::OPERATION_FORMATS ,
84
+ ],
85
+ [
86
+ 'get ' => ['method ' => 'GET ' ] + self ::OPERATION_FORMATS ,
87
+ ],
88
+ []
89
+ );
90
+
77
91
$ subresourceOperationFactoryProphecy = $ this ->prophesize (SubresourceOperationFactoryInterface::class);
78
92
$ subresourceOperationFactoryProphecy ->create (Argument::any (), Argument::any (), Argument::any ())->willReturn ([]);
79
93
80
94
$ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
81
95
$ resourceMetadataFactoryProphecy ->create (Dummy::class)->shouldBeCalled ()->willReturn ($ dummyMetadata );
96
+ $ resourceMetadataFactoryProphecy ->create ('Zorro ' )->shouldBeCalled ()->willReturn ($ zorroMetadata );
82
97
83
98
$ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
84
99
$ propertyMetadataFactoryProphecy ->create (Dummy::class, 'id ' , Argument::any ())->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_INT ), 'This is an id. ' , true , false , null , null , null , true , null , null , null , null , null , null , null , ['minLength ' => 3 , 'maxLength ' => 20 , 'pattern ' => '^dummyPattern$ ' ]));
85
100
$ propertyMetadataFactoryProphecy ->create (Dummy::class, 'name ' , Argument::any ())->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), 'This is a name. ' , true , true , true , true , false , false , null , null , [], null , null , null , null ));
86
101
$ propertyMetadataFactoryProphecy ->create (Dummy::class, 'description ' , Argument::any ())->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), 'This is an initializable but not writable property. ' , true , false , true , true , false , false , null , null , [], null , true ));
87
102
$ propertyMetadataFactoryProphecy ->create (Dummy::class, 'dummyDate ' , Argument::any ())->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_OBJECT , true , \DateTime::class), 'This is a \DateTimeInterface object. ' , true , true , true , true , false , false , null , null , []));
88
103
104
+ $ propertyMetadataFactoryProphecy ->create ('Zorro ' , 'id ' , Argument::any ())->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_INT ), 'This is an id. ' , true , false , null , null , null , true ));
105
+
89
106
$ operationPathResolver = new CustomOperationPathResolver (new OperationPathResolver (new UnderscorePathSegmentNameGenerator ()));
90
107
$ filterLocatorProphecy = $ this ->prophesize (ContainerInterface::class);
91
108
$ resourceMetadataFactory = $ resourceMetadataFactoryProphecy ->reveal ();
@@ -165,5 +182,8 @@ public function testNormalize()
165
182
// Security can be disabled per-operation using an empty array
166
183
$ this ->assertEquals ([], $ openApiAsArray ['paths ' ]['/dummies ' ]['post ' ]['security ' ]);
167
184
$ this ->assertEquals (['url ' => '/test ' ], $ openApiAsArray ['paths ' ]['/dummies ' ]['post ' ]['servers ' ]);
185
+
186
+ // Make sure things are sorted
187
+ $ this ->assertEquals (array_keys ($ openApiAsArray ['paths ' ]), ['/dummies ' , '/dummies/{id} ' , '/zorros ' , '/zorros/{id} ' ]);
168
188
}
169
189
}
0 commit comments