File tree Expand file tree Collapse file tree 3 files changed +89
-0
lines changed
tests/Fixtures/TestBundle/Entity Expand file tree Collapse file tree 3 files changed +89
-0
lines changed Original file line number Diff line number Diff line change 90
90
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyDtoCustom ;
91
91
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyDtoNoInput ;
92
92
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyDtoNoOutput ;
93
+ use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyDtoOutputSameClass ;
93
94
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyFriend ;
94
95
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyGroup ;
95
96
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyImmutableDate ;
@@ -1379,6 +1380,19 @@ public function thereAreNbDummyDtoCustom($nb)
1379
1380
$ this ->manager ->clear ();
1380
1381
}
1381
1382
1383
+ /**
1384
+ * @Given there is a DummyDtoOutputSameClass
1385
+ */
1386
+ public function thereIsADummyDtoOutputSameClass ()
1387
+ {
1388
+ $ dto = new DummyDtoOutputSameClass ();
1389
+ $ dto ->lorem = 'test ' ;
1390
+ $ dto ->ipsum = '1 ' ;
1391
+ $ this ->manager ->persist ($ dto );
1392
+ $ this ->manager ->flush ();
1393
+ $ this ->manager ->clear ();
1394
+ }
1395
+
1382
1396
/**
1383
1397
* @Given there is an order with same customer and recipient
1384
1398
*/
Original file line number Diff line number Diff line change @@ -83,6 +83,25 @@ Feature: JSON-LD DTO input and output
83
83
}
84
84
"""
85
85
86
+ @createSchema
87
+ Scenario : Get an item with same class as custom output
88
+ Given there is a DummyDtoOutputSameClass
89
+ When I send a "GET" request to "/dummy_dto_output_same_classes/1"
90
+ Then the response status code should be 200
91
+ And the response should be in JSON
92
+ And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
93
+ And the JSON should be equal to:
94
+ """
95
+ {
96
+ "@context": "/contexts/DummyDtoOutputSameClass",
97
+ "@id": "/dummy_dto_output_same_classes/1",
98
+ "@type": "DummyDtoOutputSameClass",
99
+ "lorem": "test",
100
+ "ipsum": "1",
101
+ "id": 1
102
+ }
103
+ """
104
+
86
105
@createSchema
87
106
Scenario : Create a DummyDtoCustom object without output
88
107
When I send a "POST" request to "/dummy_dto_custom_post_without_output" with body:
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the API Platform project.
5
+ *
6
+ * (c) Kévin Dunglas <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ declare (strict_types=1 );
13
+
14
+ namespace ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity ;
15
+
16
+ use ApiPlatform \Core \Annotation \ApiResource ;
17
+ use Doctrine \ORM \Mapping as ORM ;
18
+
19
+ /**
20
+ * Dummy InputOutput.
21
+ *
22
+ * @author Kévin Dunglas <[email protected] >
23
+ *
24
+ * @ApiResource(attributes={"output"=DummyDtoOutputSameClass::class})
25
+ * @ORM\Entity
26
+ */
27
+ class DummyDtoOutputSameClass
28
+ {
29
+ /**
30
+ * @var int The id
31
+ *
32
+ * @ORM\Column(type="integer")
33
+ * @ORM\Id
34
+ * @ORM\GeneratedValue(strategy="AUTO")
35
+ */
36
+ private $ id ;
37
+
38
+ /**
39
+ * @var string
40
+ *
41
+ * @ORM\Column
42
+ */
43
+ public $ lorem ;
44
+
45
+ /**
46
+ * @var string
47
+ *
48
+ * @ORM\Column
49
+ */
50
+ public $ ipsum ;
51
+
52
+ public function getId ()
53
+ {
54
+ return $ this ->id ;
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments