Skip to content

Commit dfc1771

Browse files
committed
Merge branch '2.5'
2 parents 1931f16 + c5b46f6 commit dfc1771

File tree

28 files changed

+611
-159
lines changed

28 files changed

+611
-159
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* Add basic infrastructure for cursor-based pagination (#2532)
3737
* Change ExistsFilter syntax to `exists[property]`, old syntax still supported see #2243, fixes it's behavior on GraphQL (also related #2640).
3838
* Pagination with subresources (#2698)
39-
* Improve search filter id's managment (#1844)
39+
* Improve search filter id's management (#1844)
4040
* Add support of name converter in filters (#2751, #2897), filter signature in abstract methods has changed see b42dfd198b1644904fd6a684ab2cedaf530254e3
4141
* Ability to change the Vary header via `cacheHeaders` attributes of a resource (#2758)
4242
* Ability to use the Query object in a paginator (#2493)
@@ -153,7 +153,7 @@ Please read #2825 if you have issues with the behavior of Readable/Writable Link
153153

154154
## 2.4.2
155155

156-
* Fix a dependency injection injection problem in `FilterEagerLoadingExtension`
156+
* Fix a dependency injection problem in `FilterEagerLoadingExtension`
157157
* Improve performance by adding a `NoOpScalarNormalizer` handling scalar values
158158

159159
## 2.4.1

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"doctrine/data-fixtures": "^1.2.2",
3737
"doctrine/doctrine-bundle": "^1.8",
3838
"doctrine/doctrine-cache-bundle": "^1.3.5",
39-
"doctrine/mongodb-odm": "^2.0@rc",
40-
"doctrine/mongodb-odm-bundle": "^4.0@rc",
39+
"doctrine/mongodb-odm": "^2.0",
40+
"doctrine/mongodb-odm-bundle": "^4.0",
4141
"doctrine/orm": "^2.6.3",
4242
"elasticsearch/elasticsearch": "^6.0",
4343
"friendsofsymfony/user-bundle": "^2.2@dev",
@@ -89,8 +89,7 @@
8989
},
9090
"conflict": {
9191
"doctrine/common": "<2.7",
92-
"doctrine/mongodb-odm": "<2.0",
93-
"doctrine/mongodb-odm-bundle": "4.0.0-RC2"
92+
"doctrine/mongodb-odm": "<2.0"
9493
},
9594
"suggest": {
9695
"doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",

features/json/relation.feature

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
Feature: JSON relations support
2+
In order to use a hypermedia API
3+
As a client software developer
4+
I need to be able to update relations between resources
5+
6+
@createSchema
7+
Scenario: Create a third level
8+
When I add "Content-Type" header equal to "application/json"
9+
And I send a "POST" request to "/third_levels" with body:
10+
"""
11+
{
12+
"level": 3
13+
}
14+
"""
15+
Then the response status code should be 201
16+
And the response should be in JSON
17+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
18+
And the JSON should be equal to:
19+
"""
20+
{
21+
"@context": "/contexts/ThirdLevel",
22+
"@id": "/third_levels/1",
23+
"@type": "ThirdLevel",
24+
"fourthLevel": null,
25+
"badFourthLevel": null,
26+
"id": 1,
27+
"level": 3,
28+
"test": true
29+
}
30+
"""
31+
32+
Scenario: Create a new relation
33+
When I add "Content-Type" header equal to "application/json"
34+
And I send a "POST" request to "/relation_embedders" with body:
35+
"""
36+
{
37+
"anotherRelated": {
38+
"symfony": "laravel"
39+
}
40+
}
41+
"""
42+
Then the response status code should be 201
43+
And the response should be in JSON
44+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
45+
And the JSON should be equal to:
46+
"""
47+
{
48+
"@context": "/contexts/RelationEmbedder",
49+
"@id": "/relation_embedders/1",
50+
"@type": "RelationEmbedder",
51+
"krondstadt": "Krondstadt",
52+
"anotherRelated": {
53+
"@id": "/related_dummies/1",
54+
"@type": "https://schema.org/Product",
55+
"symfony": "laravel",
56+
"thirdLevel": null
57+
},
58+
"related": null
59+
}
60+
"""
61+
62+
Scenario: Update the relation with a new one
63+
When I add "Content-Type" header equal to "application/json"
64+
And I send a "PUT" request to "/relation_embedders/1" with body:
65+
"""
66+
{
67+
"anotherRelated": {
68+
"symfony": "laravel2"
69+
}
70+
}
71+
"""
72+
Then the response status code should be 200
73+
And the response should be in JSON
74+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
75+
And the JSON should be equal to:
76+
"""
77+
{
78+
"@context": "/contexts/RelationEmbedder",
79+
"@id": "/relation_embedders/1",
80+
"@type": "RelationEmbedder",
81+
"krondstadt": "Krondstadt",
82+
"anotherRelated": {
83+
"@id": "/related_dummies/2",
84+
"@type": "https://schema.org/Product",
85+
"symfony": "laravel2",
86+
"thirdLevel": null
87+
},
88+
"related": null
89+
}
90+
"""
91+
92+
Scenario: Update an embedded relation using an IRI
93+
When I add "Content-Type" header equal to "application/json"
94+
And I send a "PUT" request to "/relation_embedders/1" with body:
95+
"""
96+
{
97+
"anotherRelated": {
98+
"id": "/related_dummies/1",
99+
"symfony": "API Platform"
100+
}
101+
}
102+
"""
103+
Then the response status code should be 200
104+
And the response should be in JSON
105+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
106+
And the JSON should be equal to:
107+
"""
108+
{
109+
"@context": "/contexts/RelationEmbedder",
110+
"@id": "/relation_embedders/1",
111+
"@type": "RelationEmbedder",
112+
"krondstadt": "Krondstadt",
113+
"anotherRelated": {
114+
"@id": "/related_dummies/1",
115+
"@type": "https://schema.org/Product",
116+
"symfony": "API Platform",
117+
"thirdLevel": null
118+
},
119+
"related": null
120+
}
121+
"""
122+
123+
Scenario: Update an embedded relation using plain identifiers
124+
When I add "Content-Type" header equal to "application/json"
125+
And I send a "PUT" request to "/relation_embedders/1" with body:
126+
"""
127+
{
128+
"anotherRelated": {
129+
"id": 1,
130+
"symfony": "API Platform 2"
131+
}
132+
}
133+
"""
134+
Then the response status code should be 200
135+
And the response should be in JSON
136+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
137+
And the JSON should be equal to:
138+
"""
139+
{
140+
"@context": "/contexts/RelationEmbedder",
141+
"@id": "/relation_embedders/1",
142+
"@type": "RelationEmbedder",
143+
"krondstadt": "Krondstadt",
144+
"anotherRelated": {
145+
"@id": "/related_dummies/1",
146+
"@type": "https://schema.org/Product",
147+
"symfony": "API Platform 2",
148+
"thirdLevel": null
149+
},
150+
"related": null
151+
}
152+
"""
153+
154+
Scenario: Create a related dummy with a relation
155+
When I add "Content-Type" header equal to "application/json"
156+
And I send a "POST" request to "/related_dummies" with body:
157+
"""
158+
{
159+
"thirdLevel": "1"
160+
}
161+
"""
162+
Then the response status code should be 201
163+
And the response should be in JSON
164+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
165+
And the JSON should be equal to:
166+
"""
167+
{
168+
"@context": "/contexts/RelatedDummy",
169+
"@id": "/related_dummies/3",
170+
"@type": "https://schema.org/Product",
171+
"id": 3,
172+
"name": null,
173+
"symfony": "symfony",
174+
"dummyDate": null,
175+
"thirdLevel": {
176+
"@id": "/third_levels/1",
177+
"@type": "ThirdLevel",
178+
"fourthLevel": null
179+
},
180+
"relatedToDummyFriend": [],
181+
"dummyBoolean": null,
182+
"embeddedDummy": [],
183+
"age": null
184+
}
185+
"""
186+
187+
Scenario: Passing a (valid) plain identifier on a relation
188+
When I add "Content-Type" header equal to "application/json"
189+
And I send a "POST" request to "/dummies" with body:
190+
"""
191+
{
192+
"relatedDummy": "1",
193+
"relatedDummies": [
194+
"1"
195+
],
196+
"name": "Dummy with plain relations"
197+
}
198+
"""
199+
Then the response status code should be 201
200+
And the response should be in JSON
201+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
202+
And the JSON should be equal to:
203+
"""
204+
{
205+
"@context": "/contexts/Dummy",
206+
"@id": "/dummies/1",
207+
"@type": "Dummy",
208+
"description": null,
209+
"dummy": null,
210+
"dummyBoolean": null,
211+
"dummyDate": null,
212+
"dummyFloat": null,
213+
"dummyPrice": null,
214+
"relatedDummy": "/related_dummies/1",
215+
"relatedDummies": [
216+
"/related_dummies/1"
217+
],
218+
"jsonData": [],
219+
"arrayData": [],
220+
"name_converted": null,
221+
"relatedOwnedDummy": null,
222+
"relatedOwningDummy": null,
223+
"id": 1,
224+
"name": "Dummy with plain relations",
225+
"alias": null,
226+
"foo": null
227+
}
228+
"""

0 commit comments

Comments
 (0)