Skip to content

Commit

Permalink
Merge branch '2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Oct 14, 2019
2 parents 1931f16 + c5b46f6 commit dfc1771
Show file tree
Hide file tree
Showing 28 changed files with 611 additions and 159 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Expand Up @@ -36,7 +36,7 @@
* Add basic infrastructure for cursor-based pagination (#2532)
* Change ExistsFilter syntax to `exists[property]`, old syntax still supported see #2243, fixes it's behavior on GraphQL (also related #2640).
* Pagination with subresources (#2698)
* Improve search filter id's managment (#1844)
* Improve search filter id's management (#1844)
* Add support of name converter in filters (#2751, #2897), filter signature in abstract methods has changed see b42dfd198b1644904fd6a684ab2cedaf530254e3
* Ability to change the Vary header via `cacheHeaders` attributes of a resource (#2758)
* Ability to use the Query object in a paginator (#2493)
Expand Down Expand Up @@ -153,7 +153,7 @@ Please read #2825 if you have issues with the behavior of Readable/Writable Link

## 2.4.2

* Fix a dependency injection injection problem in `FilterEagerLoadingExtension`
* Fix a dependency injection problem in `FilterEagerLoadingExtension`
* Improve performance by adding a `NoOpScalarNormalizer` handling scalar values

## 2.4.1
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Expand Up @@ -36,8 +36,8 @@
"doctrine/data-fixtures": "^1.2.2",
"doctrine/doctrine-bundle": "^1.8",
"doctrine/doctrine-cache-bundle": "^1.3.5",
"doctrine/mongodb-odm": "^2.0@rc",
"doctrine/mongodb-odm-bundle": "^4.0@rc",
"doctrine/mongodb-odm": "^2.0",
"doctrine/mongodb-odm-bundle": "^4.0",
"doctrine/orm": "^2.6.3",
"elasticsearch/elasticsearch": "^6.0",
"friendsofsymfony/user-bundle": "^2.2@dev",
Expand Down Expand Up @@ -89,8 +89,7 @@
},
"conflict": {
"doctrine/common": "<2.7",
"doctrine/mongodb-odm": "<2.0",
"doctrine/mongodb-odm-bundle": "4.0.0-RC2"
"doctrine/mongodb-odm": "<2.0"
},
"suggest": {
"doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",
Expand Down
228 changes: 228 additions & 0 deletions features/json/relation.feature
@@ -0,0 +1,228 @@
Feature: JSON relations support
In order to use a hypermedia API
As a client software developer
I need to be able to update relations between resources

@createSchema
Scenario: Create a third level
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/third_levels" with body:
"""
{
"level": 3
}
"""
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:
"""
{
"@context": "/contexts/ThirdLevel",
"@id": "/third_levels/1",
"@type": "ThirdLevel",
"fourthLevel": null,
"badFourthLevel": null,
"id": 1,
"level": 3,
"test": true
}
"""

Scenario: Create a new relation
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/relation_embedders" with body:
"""
{
"anotherRelated": {
"symfony": "laravel"
}
}
"""
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:
"""
{
"@context": "/contexts/RelationEmbedder",
"@id": "/relation_embedders/1",
"@type": "RelationEmbedder",
"krondstadt": "Krondstadt",
"anotherRelated": {
"@id": "/related_dummies/1",
"@type": "https://schema.org/Product",
"symfony": "laravel",
"thirdLevel": null
},
"related": null
}
"""

Scenario: Update the relation with a new one
When I add "Content-Type" header equal to "application/json"
And I send a "PUT" request to "/relation_embedders/1" with body:
"""
{
"anotherRelated": {
"symfony": "laravel2"
}
}
"""
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:
"""
{
"@context": "/contexts/RelationEmbedder",
"@id": "/relation_embedders/1",
"@type": "RelationEmbedder",
"krondstadt": "Krondstadt",
"anotherRelated": {
"@id": "/related_dummies/2",
"@type": "https://schema.org/Product",
"symfony": "laravel2",
"thirdLevel": null
},
"related": null
}
"""

Scenario: Update an embedded relation using an IRI
When I add "Content-Type" header equal to "application/json"
And I send a "PUT" request to "/relation_embedders/1" with body:
"""
{
"anotherRelated": {
"id": "/related_dummies/1",
"symfony": "API Platform"
}
}
"""
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:
"""
{
"@context": "/contexts/RelationEmbedder",
"@id": "/relation_embedders/1",
"@type": "RelationEmbedder",
"krondstadt": "Krondstadt",
"anotherRelated": {
"@id": "/related_dummies/1",
"@type": "https://schema.org/Product",
"symfony": "API Platform",
"thirdLevel": null
},
"related": null
}
"""

Scenario: Update an embedded relation using plain identifiers
When I add "Content-Type" header equal to "application/json"
And I send a "PUT" request to "/relation_embedders/1" with body:
"""
{
"anotherRelated": {
"id": 1,
"symfony": "API Platform 2"
}
}
"""
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:
"""
{
"@context": "/contexts/RelationEmbedder",
"@id": "/relation_embedders/1",
"@type": "RelationEmbedder",
"krondstadt": "Krondstadt",
"anotherRelated": {
"@id": "/related_dummies/1",
"@type": "https://schema.org/Product",
"symfony": "API Platform 2",
"thirdLevel": null
},
"related": null
}
"""

Scenario: Create a related dummy with a relation
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/related_dummies" with body:
"""
{
"thirdLevel": "1"
}
"""
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:
"""
{
"@context": "/contexts/RelatedDummy",
"@id": "/related_dummies/3",
"@type": "https://schema.org/Product",
"id": 3,
"name": null,
"symfony": "symfony",
"dummyDate": null,
"thirdLevel": {
"@id": "/third_levels/1",
"@type": "ThirdLevel",
"fourthLevel": null
},
"relatedToDummyFriend": [],
"dummyBoolean": null,
"embeddedDummy": [],
"age": null
}
"""

Scenario: Passing a (valid) plain identifier on a relation
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/dummies" with body:
"""
{
"relatedDummy": "1",
"relatedDummies": [
"1"
],
"name": "Dummy with plain relations"
}
"""
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:
"""
{
"@context": "/contexts/Dummy",
"@id": "/dummies/1",
"@type": "Dummy",
"description": null,
"dummy": null,
"dummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
"relatedDummy": "/related_dummies/1",
"relatedDummies": [
"/related_dummies/1"
],
"jsonData": [],
"arrayData": [],
"name_converted": null,
"relatedOwnedDummy": null,
"relatedOwningDummy": null,
"id": 1,
"name": "Dummy with plain relations",
"alias": null,
"foo": null
}
"""

0 comments on commit dfc1771

Please sign in to comment.