Skip to content

Commit 6e9e907

Browse files
committed
add feature reproducing bug
1 parent 42079f3 commit 6e9e907

File tree

4 files changed

+60
-10
lines changed

4 files changed

+60
-10
lines changed

features/main/crud_abstract.feature

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,20 @@ Feature: Create-Retrieve-Update-Delete on abstract resource
8080
"""
8181

8282
Scenario: Update a concrete resource
83-
When I add "Content-Type" header equal to "application/ld+json"
84-
And I send a "PUT" request to "/concrete_dummies/1" with body:
83+
When I add "Content-Type" header equal to "application/ld+json"
84+
And I send a "PUT" request to "/concrete_dummies/1" with body:
8585
"""
8686
{
8787
"@id": "/concrete_dummies/1",
8888
"instance": "Become real",
8989
"name": "A nice dummy"
9090
}
9191
"""
92-
Then the response status code should be 200
93-
And the response should be in JSON
94-
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
95-
And the header "Content-Location" should be equal to "/concrete_dummies/1"
96-
And the JSON should be equal to:
92+
Then the response status code should be 200
93+
And the response should be in JSON
94+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
95+
And the header "Content-Location" should be equal to "/concrete_dummies/1"
96+
And the JSON should be equal to:
9797
"""
9898
{
9999
"@context": "/contexts/ConcreteDummy",
@@ -105,6 +105,32 @@ Feature: Create-Retrieve-Update-Delete on abstract resource
105105
}
106106
"""
107107

108+
Scenario: Update a concrete resource using abstract resource uri
109+
When I add "Content-Type" header equal to "application/ld+json"
110+
And I send a "PUT" request to "/abstract_dummies/1" with body:
111+
"""
112+
{
113+
"@id": "/concrete_dummies/1",
114+
"instance": "Become surreal",
115+
"name": "A nicer dummy"
116+
}
117+
"""
118+
Then the response status code should be 200
119+
And the response should be in JSON
120+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
121+
And the header "Content-Location" should be equal to "/concrete_dummies/1"
122+
And the JSON should be equal to:
123+
"""
124+
{
125+
"@context": "/contexts/ConcreteDummy",
126+
"@id": "/concrete_dummies/1",
127+
"@type": "ConcreteDummy",
128+
"instance": "Become surreal",
129+
"id": 1,
130+
"name": "A nicer dummy"
131+
}
132+
"""
133+
108134
Scenario: Delete a resource
109135
When I send a "DELETE" request to "/abstract_dummies/1"
110136
Then the response status code should be 204

tests/Fixtures/TestBundle/Document/AbstractDummy.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
* Abstract Dummy.
2323
*
2424
* @author Jérémy Derussé <[email protected]>
25-
*
26-
* @ApiResource(attributes={"filters"={"my_dummy.mongodb.search", "my_dummy.mongodb.order", "my_dummy.mongodb.date"}})
25+
* @ApiResource(
26+
* itemOperations={
27+
* "get",
28+
* "put",
29+
* "delete",
30+
* },
31+
* attributes={"filters"={"my_dummy.mongodb.search", "my_dummy.mongodb.order", "my_dummy.mongodb.date"}}
32+
* )
2733
* @ODM\Document
2834
* @ODM\InheritanceType("SINGLE_COLLECTION")
2935
* @ODM\DiscriminatorField(value="discr")

tests/Fixtures/TestBundle/Entity/AbstractDummy.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323
*
2424
* @author Jérémy Derussé <[email protected]>
2525
*
26-
* @ApiResource(attributes={"filters"={"my_dummy.search", "my_dummy.order", "my_dummy.date"}})
26+
* @ApiResource(
27+
* itemOperations={
28+
* "get",
29+
* "put",
30+
* "delete",
31+
* },
32+
* attributes={"filters"={"my_dummy.search", "my_dummy.order", "my_dummy.date"}}
33+
* )
2734
* @ORM\Entity
2835
* @ORM\InheritanceType("SINGLE_TABLE")
2936
* @ORM\DiscriminatorColumn(name="discr", type="string", length=16)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\AbstractDummy:
2+
discriminator_map:
3+
type_property: discr
4+
mapping:
5+
concrete: 'ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ConcreteDummy'
6+
7+
ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\AbstractDummy:
8+
discriminator_map:
9+
type_property: discr
10+
mapping:
11+
concrete: 'ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ConcreteDummy'

0 commit comments

Comments
 (0)