Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 10, 2020
1 parent 43df5dd commit 2fffa84
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion features/graphql/input_output.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: GraphQL DTO input and output
}
"""
Then the response status code should be 201
And the JSON should be equal to:
And the JSON should be a superset of:
"""
{
"@context": {
Expand All @@ -43,6 +43,7 @@ Feature: GraphQL DTO input and output
"relatedToDummyFriend": [],
"dummyBoolean": null,
"embeddedDummy": {
"@type": "EmbeddableDummy",
"dummyName": null,
"dummyBoolean": null,
"dummyDate": null,
Expand Down
7 changes: 5 additions & 2 deletions features/jsonld/non_resource.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: JSON-LD non-resource handling
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
And the JSON should be a superset of:
"""
{
"@context": "/contexts/ContainNonResource",
Expand All @@ -25,11 +25,13 @@ Feature: JSON-LD non-resource handling
"id": "1-nested",
"nested": null,
"notAResource": {
"@type": "NotAResource",
"foo": "f2",
"bar": "b2"
}
},
"notAResource": {
"@type": "NotAResource",
"foo": "f1",
"bar": "b1"
}
Expand All @@ -50,13 +52,14 @@ Feature: JSON-LD non-resource handling
Then the response status code should be 201
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
And the JSON should be a superset of:
"""
{
"@context": "/contexts/NonRelationResource",
"@id": "/non_relation_resources/1",
"@type": "NonRelationResource",
"relation": {
"@type": "NonResourceClass",
"foo": "test"
},
"id": 1
Expand Down
17 changes: 9 additions & 8 deletions features/main/operation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ Feature: Operation support
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
And the JSON should be a superset of:
"""
{
"@context": "/contexts/EmbeddedDummy",
"@id": "/embedded_dummies/1",
"@type": "EmbeddedDummy",
"name": "Dummy #1",
"embeddedDummy": {
"dummyName": "Dummy #1"
}
"@context": "/contexts/EmbeddedDummy",
"@id": "/embedded_dummies/1",
"@type": "EmbeddedDummy",
"name": "Dummy #1",
"embeddedDummy": {
"@type": "EmbeddableDummy",
"dummyName": "Dummy #1"
}
}
"""

Expand Down
3 changes: 2 additions & 1 deletion features/main/relation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Feature: Relations support
And I send a "GET" request to "/people"
Then the response status code should be 200
And the response should be in JSON
And the JSON should be equal to:
And the JSON should be a superset of:
"""
{
"@context": "/contexts/Person",
Expand All @@ -415,6 +415,7 @@ Feature: Relations support
"name": "foo",
"pets": [
{
"@type": "PersonToPet",
"pet": {
"@id": "/pets/1",
"@type": "Pet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Resource with constructor deserializable
Then the response status code should be 201
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
And the JSON should be a superset of:
"""
{
"@context": "/contexts/DummyEntityWithConstructor",
Expand All @@ -32,6 +32,7 @@ Feature: Resource with constructor deserializable
"bar": "world",
"items": [
{
"@type": "DummyObjectWithoutConstructor",
"foo": "bar"
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/JsonLd/Serializer/ObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function normalize($object, $format = null, array $context = [])
$context['api_empty_resource_as_iri'] = true;

$data = $this->decorated->normalize($object, $format, $context);
if (!\is_array($data)) {
if (!\is_array($data) || !$data) {
return $data;
}

Expand Down

0 comments on commit 2fffa84

Please sign in to comment.