Skip to content

Commit 39e21ea

Browse files
Update tests
1 parent 0b0c8b8 commit 39e21ea

File tree

6 files changed

+115
-100
lines changed

6 files changed

+115
-100
lines changed

features/hydra/docs.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Feature: Documentation support
1313
And the response should be in JSON
1414
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
1515
# Context
16-
And the Hydra context matches the online resource "http://www.w3.org/ns/hydra/context.jsonld"
16+
And the Hydra context matches the online resource "http://www.w3.org/ns/hydra/context.jsonld.output"
1717
And the JSON node "@context[1].@vocab" should be equal to "http://example.com/docs.jsonld#"
1818
And the JSON node "@context[1].hydra" should be equal to "http://www.w3.org/ns/hydra/core#"
1919
And the JSON node "@context[1].rdf" should be equal to "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

tests/Functional/JsonSchema/JsonApiJsonSchemaTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function getResources(): array
5858
public function testJsonApi(): void
5959
{
6060
$speciesSchema = $this->schemaFactory->buildSchema(Issue6317::class, 'jsonapi', Schema::TYPE_OUTPUT);
61-
$this->assertEquals('#/definitions/Issue6317.jsonapi', $speciesSchema['$ref']);
61+
$this->assertEquals('#/definitions/Issue6317.jsonapi.output', $speciesSchema['$ref']);
6262
$this->assertEquals([
6363
'properties' => [
6464
'data' => [
@@ -71,7 +71,7 @@ public function testJsonApi(): void
7171
'type' => 'string',
7272
],
7373
'attributes' => [
74-
'$ref' => '#/definitions/Issue6317',
74+
'$ref' => '#/definitions/Issue6317.output',
7575
],
7676
],
7777
'required' => [
@@ -80,7 +80,7 @@ public function testJsonApi(): void
8080
],
8181
],
8282
],
83-
], $speciesSchema['definitions']['Issue6317.jsonapi']);
83+
], $speciesSchema['definitions']['Issue6317.jsonapi.output']);
8484
}
8585

8686
public function testJsonApiIncludesSchemaForQuestion(): void
@@ -91,48 +91,48 @@ public function testJsonApiIncludesSchemaForQuestion(): void
9191

9292
$questionSchema = $this->schemaFactory->buildSchema(Question::class, 'jsonapi', Schema::TYPE_OUTPUT);
9393
$json = $questionSchema->getDefinitions();
94-
$properties = $json['Question.jsonapi']['properties']['data']['properties'];
95-
$included = $json['Question.jsonapi']['properties']['included'];
94+
$properties = $json['Question.jsonapi.output']['properties']['data']['properties'];
95+
$included = $json['Question.jsonapi.output']['properties']['included'];
9696

9797
$this->assertArrayHasKey('answer', $properties['relationships']['properties']);
9898
$this->assertArrayHasKey('anyOf', $included['items']);
9999
$this->assertCount(1, $included['items']['anyOf']);
100100
$this->assertArrayHasKey('$ref', $included['items']['anyOf'][0]);
101-
$this->assertSame('#/definitions/Answer.jsonapi', $included['items']['anyOf'][0]['$ref']);
101+
$this->assertSame('#/definitions/Answer.jsonapi.output', $included['items']['anyOf'][0]['$ref']);
102102
}
103103

104104
public function testJsonApiIncludesSchemaForAnimalObservation(): void
105105
{
106106
$animalObservationSchema = $this->schemaFactory->buildSchema(AnimalObservation::class, 'jsonapi', Schema::TYPE_OUTPUT);
107107
$json = $animalObservationSchema->getDefinitions();
108-
$properties = $json['AnimalObservation.jsonapi']['properties']['data']['properties'];
109-
$included = $json['AnimalObservation.jsonapi']['properties']['included'];
108+
$properties = $json['AnimalObservation.jsonapi.output']['properties']['data']['properties'];
109+
$included = $json['AnimalObservation.jsonapi.output']['properties']['included'];
110110

111111
$this->assertArrayHasKey('individuals', $properties['relationships']['properties']);
112112
$this->assertArrayHasKey('anyOf', $included['items']);
113113
$this->assertCount(1, $included['items']['anyOf']);
114-
$this->assertSame('#/definitions/Animal.jsonapi', $included['items']['anyOf'][0]['$ref']);
114+
$this->assertSame('#/definitions/Animal.jsonapi.output', $included['items']['anyOf'][0]['$ref']);
115115
}
116116

117117
public function testJsonApiIncludesSchemaForAnimal(): void
118118
{
119119
$animalSchema = $this->schemaFactory->buildSchema(Animal::class, 'jsonapi', Schema::TYPE_OUTPUT);
120120
$json = $animalSchema->getDefinitions();
121-
$properties = $json['Animal.jsonapi']['properties']['data']['properties'];
122-
$included = $json['Animal.jsonapi']['properties']['included'];
121+
$properties = $json['Animal.jsonapi.output']['properties']['data']['properties'];
122+
$included = $json['Animal.jsonapi.output']['properties']['included'];
123123

124124
$this->assertArrayHasKey('species', $properties['relationships']['properties']);
125125
$this->assertArrayHasKey('anyOf', $included['items']);
126126
$this->assertCount(1, $included['items']['anyOf']);
127-
$this->assertSame('#/definitions/Species.jsonapi', $included['items']['anyOf'][0]['$ref']);
127+
$this->assertSame('#/definitions/Species.jsonapi.output', $included['items']['anyOf'][0]['$ref']);
128128
}
129129

130130
public function testJsonApiIncludesSchemaForSpecies(): void
131131
{
132132
$speciesSchema = $this->schemaFactory->buildSchema(Species::class, 'jsonapi', Schema::TYPE_OUTPUT, forceCollection: true);
133133
$this->assertArraySubset(
134134
[
135-
'description' => 'Species.jsonapi collection.',
135+
'description' => 'Species.jsonapi.output collection.',
136136
'allOf' => [
137137
['$ref' => '#/definitions/JsonApiCollectionBaseSchema'],
138138
[
@@ -150,7 +150,7 @@ public function testJsonApiIncludesSchemaForSpecies(): void
150150
'type' => 'string',
151151
],
152152
'attributes' => [
153-
'$ref' => '#/definitions/Species',
153+
'$ref' => '#/definitions/Species.output',
154154
],
155155
],
156156
'required' => [

tests/Functional/JsonSchema/JsonLdJsonSchemaTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public function testSubSchemaJsonLd(): void
7474
'nonResourceTests' => new \ArrayObject([
7575
'type' => 'array',
7676
'items' => [
77-
'$ref' => '#/definitions/NonResourceTestEntity.jsonld-read',
77+
'$ref' => '#/definitions/NonResourceTestEntity.jsonld.output-read',
7878
],
7979
]),
8080
'type' => new \ArrayObject([
81-
'$ref' => '#/definitions/TestEntity.jsonld-read',
81+
'$ref' => '#/definitions/TestEntity.jsonld.output-read',
8282
]),
8383
],
8484
]),
@@ -137,47 +137,47 @@ public function testSubSchemaJsonLd(): void
137137
]);
138138

139139
$this->assertArrayHasKey('definitions', $schema);
140-
$this->assertArrayHasKey('BagOfTests.jsonld-read', $schema['definitions']);
141-
$this->assertArrayHasKey('NonResourceTestEntity.jsonld-read', $schema['definitions']);
142-
$this->assertArrayHasKey('TestEntity.jsonld-read', $schema['definitions']);
140+
$this->assertArrayHasKey('BagOfTests.jsonld.output-read', $schema['definitions']);
141+
$this->assertArrayHasKey('NonResourceTestEntity.jsonld.output-read', $schema['definitions']);
142+
$this->assertArrayHasKey('TestEntity.jsonld.output-read', $schema['definitions']);
143143

144-
$this->assertEquals($expectedBagOfTestsSchema, $schema['definitions']['BagOfTests.jsonld-read']);
145-
$this->assertEquals($expectedNonResourceTestEntitySchema, $schema['definitions']['NonResourceTestEntity.jsonld-read']);
146-
$this->assertEquals($expectedTestEntitySchema, $schema['definitions']['TestEntity.jsonld-read']);
144+
$this->assertEquals($expectedBagOfTestsSchema, $schema['definitions']['BagOfTests.jsonld.output-read']);
145+
$this->assertEquals($expectedNonResourceTestEntitySchema, $schema['definitions']['NonResourceTestEntity.jsonld.output-read']);
146+
$this->assertEquals($expectedTestEntitySchema, $schema['definitions']['TestEntity.jsonld.output-read']);
147147

148-
$this->assertEquals('#/definitions/BagOfTests.jsonld-read', $schema['$ref']);
148+
$this->assertEquals('#/definitions/BagOfTests.jsonld.output-read', $schema['$ref']);
149149
}
150150

151151
public function testSchemaJsonLdCollection(): void
152152
{
153153
$schema = $this->schemaFactory->buildSchema(BagOfTests::class, 'jsonld', forceCollection: true);
154154

155155
$this->assertArrayHasKey('definitions', $schema);
156-
$this->assertArrayHasKey('BagOfTests.jsonld-read', $schema['definitions']);
157-
$this->assertArrayHasKey('NonResourceTestEntity.jsonld-read', $schema['definitions']);
158-
$this->assertArrayHasKey('TestEntity.jsonld-read', $schema['definitions']);
156+
$this->assertArrayHasKey('BagOfTests.jsonld.output-read', $schema['definitions']);
157+
$this->assertArrayHasKey('NonResourceTestEntity.jsonld.output-read', $schema['definitions']);
158+
$this->assertArrayHasKey('TestEntity.jsonld.output-read', $schema['definitions']);
159159
$this->assertArrayHasKey('HydraItemBaseSchema', $schema['definitions']);
160160
$this->assertArrayHasKey('HydraCollectionBaseSchema', $schema['definitions']);
161161

162162
$this->assertEquals(['$ref' => '#/definitions/HydraCollectionBaseSchema'], $schema['allOf'][0]);
163-
$this->assertEquals(['$ref' => '#/definitions/BagOfTests.jsonld-read'], $schema['allOf'][1]['properties']['hydra:member']['items']);
163+
$this->assertEquals(['$ref' => '#/definitions/BagOfTests.jsonld.output-read'], $schema['allOf'][1]['properties']['hydra:member']['items']);
164164
}
165165

166166
public function testArraySchemaWithMultipleUnionTypes(): void
167167
{
168168
$schema = $this->schemaFactory->buildSchema(Nest::class, 'jsonld', 'output');
169169

170-
$this->assertContains(['$ref' => '#/definitions/Robin.jsonld'], $schema['definitions']['Nest.jsonld']['allOf'][1]['properties']['owner']['anyOf']);
171-
$this->assertContains(['$ref' => '#/definitions/Wren.jsonld'], $schema['definitions']['Nest.jsonld']['allOf'][1]['properties']['owner']['anyOf']);
172-
$this->assertContains(['type' => 'null'], $schema['definitions']['Nest.jsonld']['allOf'][1]['properties']['owner']['anyOf']);
170+
$this->assertContains(['$ref' => '#/definitions/Robin.jsonld.output'], $schema['definitions']['Nest.jsonld.output']['allOf'][1]['properties']['owner']['anyOf']);
171+
$this->assertContains(['$ref' => '#/definitions/Wren.jsonld.output'], $schema['definitions']['Nest.jsonld.output']['allOf'][1]['properties']['owner']['anyOf']);
172+
$this->assertContains(['type' => 'null'], $schema['definitions']['Nest.jsonld.output']['allOf'][1]['properties']['owner']['anyOf']);
173173

174-
$this->assertArrayHasKey('Nest.jsonld', $schema['definitions']);
174+
$this->assertArrayHasKey('Nest.jsonld.output', $schema['definitions']);
175175
}
176176

177177
public function testSchemaWithoutGetOperation(): void
178178
{
179179
$schema = $this->schemaFactory->buildSchema(Boat::class, 'jsonld', 'output', $this->operationMetadataFactory->create('_api_/boats{._format}_get_collection'));
180180

181-
$this->assertEquals(['$ref' => '#/definitions/HydraItemBaseSchema'], $schema->getDefinitions()['Boat.jsonld-boat.read']['allOf'][0]);
181+
$this->assertEquals(['$ref' => '#/definitions/HydraItemBaseSchema'], $schema->getDefinitions()['Boat.jsonld.output-boat.read']['allOf'][0]);
182182
}
183183
}

0 commit comments

Comments
 (0)