@@ -122,10 +122,20 @@ public function testAssertMatchesJsonSchema(): void
122
122
$ this ->assertMatchesJsonSchema (json_decode ($ jsonSchema , true ));
123
123
}
124
124
125
- public function testAssertMatchesResourceCollectionJsonSchema (): void
125
+ public static function providerFormats (): iterable
126
126
{
127
- self ::createClient ()->request ('GET ' , '/resource_interfaces ' );
128
- $ this ->assertMatchesResourceCollectionJsonSchema (ResourceInterface::class);
127
+ // yield 'jsonapi' => ['jsonapi', 'application/vnd.api+json'];
128
+ yield 'jsonhal ' => ['jsonhal ' , 'application/hal+json ' ];
129
+ yield 'jsonld ' => ['jsonld ' , 'application/ld+json ' ];
130
+ }
131
+
132
+ /**
133
+ * @dataProvider providerFormats
134
+ */
135
+ public function testAssertMatchesResourceCollectionJsonSchema (string $ format , string $ mimeType ): void
136
+ {
137
+ self ::createClient ()->request ('GET ' , '/resource_interfaces ' , ['headers ' => ['Accept ' => $ mimeType ]]);
138
+ $ this ->assertMatchesResourceCollectionJsonSchema (ResourceInterface::class, format: $ format );
129
139
}
130
140
131
141
public function testAssertMatchesResourceCollectionJsonSchemaKeepSerializationContext (): void
@@ -173,7 +183,10 @@ public function testAssertMatchesResourceItemJsonSchemaWithCustomJson(): void
173
183
$ this ->assertMatchesResourceItemJsonSchema (JsonSchemaContextDummy::class);
174
184
}
175
185
176
- public function testAssertMatchesResourceItemJsonSchemaOutput (): void
186
+ /**
187
+ * @dataProvider providerFormats
188
+ */
189
+ public function testAssertMatchesResourceItemJsonSchemaOutput (string $ format , string $ mimeType ): void
177
190
{
178
191
$ this ->recreateSchema ();
179
192
@@ -184,8 +197,8 @@ public function testAssertMatchesResourceItemJsonSchemaOutput(): void
184
197
$ dummyDtoInputOutput ->num = 54 ;
185
198
$ manager ->persist ($ dummyDtoInputOutput );
186
199
$ manager ->flush ();
187
- self ::createClient ()->request ('GET ' , '/dummy_dto_input_outputs/1 ' );
188
- $ this ->assertMatchesResourceItemJsonSchema (DummyDtoInputOutput::class);
200
+ self ::createClient ()->request ('GET ' , '/dummy_dto_input_outputs/1 ' , [ ' headers ' => [ ' Accept ' => $ mimeType ]] );
201
+ $ this ->assertMatchesResourceItemJsonSchema (DummyDtoInputOutput::class, format: $ format );
189
202
}
190
203
191
204
public function testAssertMatchesResourceItemAndCollectionJsonSchemaOutputWithContext (): void
0 commit comments