Skip to content

Commit

Permalink
fix exsistent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ttskch committed May 13, 2024
1 parent e8b415c commit ff80dcf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions features/openapi/docs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Feature: Documentation support
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters" should have 6 elements

# Subcollection - check schema
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.content.application/ld+json.schema.properties.hydra:member.items.$ref" should be equal to "#/components/schemas/RelatedToDummyFriend.jsonld-fakemanytomany"
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.content.application/ld+json.schema.properties.hydra:member.items.$ref" should be equal to "#/components/schemas/RelatedToDummyFriend.jsonld-fakemanytomany.output"

# Deprecations
And the JSON node "paths./dummies.get.deprecated" should be false
Expand All @@ -165,8 +165,8 @@ Feature: Documentation support
And the JSON node "paths./deprecated_resources/{id}.patch.deprecated" should be true

# Formats
And the OpenAPI class "Dummy.jsonld" exists
And the "@id" property exists for the OpenAPI class "Dummy.jsonld"
And the OpenAPI class "Dummy.jsonld.output" exists
And the "@id" property exists for the OpenAPI class "Dummy.jsonld.output"
And the JSON node "paths./dummies.get.responses.200.content.application/ld+json" should be equal to:
"""
{
Expand All @@ -176,7 +176,7 @@ Feature: Documentation support
"hydra:member": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Dummy.jsonld"
"$ref": "#/components/schemas/Dummy.jsonld.output"
}
},
"hydra:totalItems": {
Expand Down
32 changes: 16 additions & 16 deletions tests/JsonSchema/Command/JsonSchemaGenerateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,24 @@ public function testArraySchemaWithReference(): void
$result = $this->tester->getDisplay();
$json = json_decode($result, associative: true);

$this->assertEquals($json['definitions']['BagOfTests.jsonld-write']['properties']['tests'], [
$this->assertEquals($json['definitions']['BagOfTests.jsonld-write.input']['properties']['tests'], [
'type' => 'string',
'foo' => 'bar',
]);

$this->assertEquals($json['definitions']['BagOfTests.jsonld-write']['properties']['nonResourceTests'], [
$this->assertEquals($json['definitions']['BagOfTests.jsonld-write.input']['properties']['nonResourceTests'], [
'type' => 'array',
'items' => [
'$ref' => '#/definitions/NonResourceTestEntity.jsonld-write',
'$ref' => '#/definitions/NonResourceTestEntity.jsonld-write.input',
],
]);

$this->assertEquals($json['definitions']['BagOfTests.jsonld-write']['properties']['description'], [
$this->assertEquals($json['definitions']['BagOfTests.jsonld-write.input']['properties']['description'], [
'maxLength' => 255,
]);

$this->assertEquals($json['definitions']['BagOfTests.jsonld-write']['properties']['type'], [
'$ref' => '#/definitions/TestEntity.jsonld-write',
$this->assertEquals($json['definitions']['BagOfTests.jsonld-write.input']['properties']['type'], [
'$ref' => '#/definitions/TestEntity.jsonld-write.input',
]);
}

Expand All @@ -130,14 +130,14 @@ public function testArraySchemaWithMultipleUnionTypesJsonLd(): void
$result = $this->tester->getDisplay();
$json = json_decode($result, associative: true);

$this->assertEquals($json['definitions']['Nest.jsonld']['properties']['owner']['anyOf'], [
['$ref' => '#/definitions/Wren.jsonld'],
['$ref' => '#/definitions/Robin.jsonld'],
$this->assertEquals($json['definitions']['Nest.jsonld.output']['properties']['owner']['anyOf'], [
['$ref' => '#/definitions/Wren.jsonld.output'],
['$ref' => '#/definitions/Robin.jsonld.output'],
['type' => 'null'],
]);

$this->assertArrayHasKey('Wren.jsonld', $json['definitions']);
$this->assertArrayHasKey('Robin.jsonld', $json['definitions']);
$this->assertArrayHasKey('Wren.jsonld.output', $json['definitions']);
$this->assertArrayHasKey('Robin.jsonld.output', $json['definitions']);
}

public function testArraySchemaWithMultipleUnionTypesJsonApi(): void
Expand Down Expand Up @@ -183,7 +183,7 @@ public function testArraySchemaWithTypeFactory(): void
$result = $this->tester->getDisplay();
$json = json_decode($result, associative: true);

$this->assertEquals($json['definitions']['Foo.jsonld']['properties']['expiration'], ['type' => 'string', 'format' => 'date']);
$this->assertEquals($json['definitions']['Foo.jsonld.output']['properties']['expiration'], ['type' => 'string', 'format' => 'date']);
}

/**
Expand All @@ -195,7 +195,7 @@ public function testWritableNonResourceRef(): void
$result = $this->tester->getDisplay();
$json = json_decode($result, associative: true);

$this->assertEquals($json['definitions']['SaveProduct.jsonld']['properties']['codes']['items']['$ref'], '#/definitions/ProductCode.jsonld');
$this->assertEquals($json['definitions']['SaveProduct.jsonld.input']['properties']['codes']['items']['$ref'], '#/definitions/ProductCode.jsonld.input');
}

/**
Expand All @@ -207,8 +207,8 @@ public function testOpenApiResourceRefIsNotOverwritten(): void
$result = $this->tester->getDisplay();
$json = json_decode($result, associative: true);

$this->assertEquals('#/definitions/DummyFriend', $json['definitions']['Issue6299.Issue6299OutputDto.jsonld']['properties']['itemDto']['$ref']);
$this->assertEquals('#/definitions/DummyDate', $json['definitions']['Issue6299.Issue6299OutputDto.jsonld']['properties']['collectionDto']['items']['$ref']);
$this->assertEquals('#/definitions/DummyFriend', $json['definitions']['Issue6299.Issue6299OutputDto.jsonld.output']['properties']['itemDto']['$ref']);
$this->assertEquals('#/definitions/DummyDate', $json['definitions']['Issue6299.Issue6299OutputDto.jsonld.output']['properties']['collectionDto']['items']['$ref']);
}

/**
Expand All @@ -220,7 +220,7 @@ public function testSubSchemaJsonLd(): void
$result = $this->tester->getDisplay();
$json = json_decode($result, associative: true);

$this->assertArrayHasKey('@id', $json['definitions']['ThirdLevel.jsonld-friends']['properties']);
$this->assertArrayHasKey('@id', $json['definitions']['ThirdLevel.jsonld-friends.output']['properties']);
}

public function testJsonApiIncludesSchema(): void
Expand Down

0 comments on commit ff80dcf

Please sign in to comment.