Skip to content

Commit 7dd4428

Browse files
committed
add further coverage for creating abstract resources with a discriminator
1 parent 2ab5c4f commit 7dd4428

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

features/main/crud_abstract.feature

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,30 @@ Feature: Create-Retrieve-Update-Delete on abstract resource
135135
When I send a "DELETE" request to "/abstract_dummies/1"
136136
Then the response status code should be 204
137137
And the response should be empty
138+
139+
Scenario: Create a concrete resource with discriminator
140+
When I add "Content-Type" header equal to "application/ld+json"
141+
And I send a "POST" request to "/abstract_dummies" with body:
142+
"""
143+
{
144+
"discr": "concrete",
145+
"instance": "Concrete",
146+
"name": "My Dummy"
147+
}
148+
"""
149+
Then the response status code should be 201
150+
And the response should be in JSON
151+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
152+
And the header "Content-Location" should be equal to "/concrete_dummies/2"
153+
And the header "Location" should be equal to "/concrete_dummies/2"
154+
And the JSON should be equal to:
155+
"""
156+
{
157+
"@context": "/contexts/ConcreteDummy",
158+
"@id": "/concrete_dummies/2",
159+
"@type": "ConcreteDummy",
160+
"instance": "Concrete",
161+
"id": 2,
162+
"name": "My Dummy"
163+
}
164+
"""

tests/Fixtures/TestBundle/Document/AbstractDummy.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
*
2424
* @author Jérémy Derussé <[email protected]>
2525
* @ApiResource(
26-
* itemOperations={
27-
* "get",
28-
* "put",
29-
* "delete",
30-
* },
26+
* collectionOperations={"get", "post"},
27+
* itemOperations={"get", "put", "delete"},
3128
* attributes={"filters"={"my_dummy.mongodb.search", "my_dummy.mongodb.order", "my_dummy.mongodb.date"}}
3229
* )
3330
* @ODM\Document

tests/Fixtures/TestBundle/Entity/AbstractDummy.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424
* @author Jérémy Derussé <[email protected]>
2525
*
2626
* @ApiResource(
27-
* itemOperations={
28-
* "get",
29-
* "put",
30-
* "delete",
31-
* },
27+
* collectionOperations={"get", "post"},
28+
* itemOperations={"get", "put", "delete"},
3229
* attributes={"filters"={"my_dummy.search", "my_dummy.order", "my_dummy.date"}}
3330
* )
3431
* @ORM\Entity

0 commit comments

Comments
 (0)