Skip to content

Commit

Permalink
Add behat test
Browse files Browse the repository at this point in the history
  • Loading branch information
norkunas committed Oct 21, 2021
1 parent 8343e2c commit b708571
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
28 changes: 28 additions & 0 deletions features/jsonld/non_resource.feature
Expand Up @@ -38,6 +38,34 @@ Feature: JSON-LD non-resource handling
}
"""

Scenario: Get a resource containing a raw object with selected properties
Given there are 1 dummy objects with relatedDummy and its thirdLevel
When I send a "GET" request to "/contain_non_resources/1?properties[]=id&properties[nested][notAResource][]=foo&properties[notARresource][]=bar"
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 a superset of:
"""
{
"@context": "/contexts/ContainNonResource",
"@id": "/contain_non_resources/1",
"@type": "ContainNonResource",
"id": 1,
"nested": {
"@id": "/contain_non_resources/1-nested",
"@type": "ContainNonResource",
"notAResource": {
"@type": "NotAResource",
"foo": "f2"
}
},
"notAResource": {
"@type": "NotAResource",
"bar": "b1"
}
}
"""

@!mongodb
@createSchema
Scenario: Create a resource that has a non-resource relation.
Expand Down
7 changes: 5 additions & 2 deletions tests/Fixtures/TestBundle/Document/ContainNonResource.php
Expand Up @@ -24,9 +24,12 @@
* @ODM\Document
*
* @ApiResource(
* normalizationContext={
* "groups"={"contain_non_resource"},
* attributes={
* "filters"={"my_dummy.property"}
* },
* normalizationContext={
* "groups"={"contain_non_resource"}
* }
* )
*
* @author Kévin Dunglas <dunglas@gmail.com>
Expand Down
7 changes: 5 additions & 2 deletions tests/Fixtures/TestBundle/Entity/ContainNonResource.php
Expand Up @@ -24,9 +24,12 @@
* @ORM\Entity
*
* @ApiResource(
* normalizationContext={
* "groups"={"contain_non_resource"},
* attributes={
* "filters"={"my_dummy.property"}
* },
* normalizationContext={
* "groups"={"contain_non_resource"}
* }
* )
*
* @author Kévin Dunglas <dunglas@gmail.com>
Expand Down

0 comments on commit b708571

Please sign in to comment.