File tree Expand file tree Collapse file tree 2 files changed +113
-0
lines changed Expand file tree Collapse file tree 2 files changed +113
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,31 @@ public function thereAreDummyPropertyObjects(int $nb)
219
219
$ this ->manager ->flush ();
220
220
}
221
221
222
+ /**
223
+ * @Given there are :nb dummy property objects with a shared group
224
+ */
225
+ public function thereAreDummyPropertyObjectsWithASharedGroup (int $ nb )
226
+ {
227
+ $ dummyGroup = new DummyGroup ();
228
+ foreach (['foo ' , 'bar ' , 'baz ' ] as $ property ) {
229
+ $ dummyGroup ->$ property = ucfirst ($ property ).' #shared ' ;
230
+ }
231
+ $ this ->manager ->persist ($ dummyGroup );
232
+
233
+ for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
234
+ $ dummyProperty = new DummyProperty ();
235
+
236
+ foreach (['foo ' , 'bar ' , 'baz ' ] as $ property ) {
237
+ $ dummyProperty ->$ property = ucfirst ($ property ).' # ' .$ i ;
238
+ }
239
+
240
+ $ dummyProperty ->group = $ dummyGroup ;
241
+ $ this ->manager ->persist ($ dummyProperty );
242
+ }
243
+
244
+ $ this ->manager ->flush ();
245
+ }
246
+
222
247
/**
223
248
* @Given there are :nb dummy property objects with :nb2 groups
224
249
*/
Original file line number Diff line number Diff line change @@ -496,3 +496,91 @@ Feature: JSON API Inclusion of Related Resources
496
496
}
497
497
"""
498
498
499
+ @createSchema
500
+ Scenario : Request inclusion of a related resources on collection should not duplicated included object
501
+ Given there are 3 dummy property objects with a shared group
502
+ When I send a "GET" request to "/dummy_properties?include=group"
503
+ Then the response status code should be 200
504
+ And the response should be in JSON
505
+ And the JSON should be valid according to the JSON API schema
506
+ And the JSON should be deep equal to:
507
+ """
508
+ {
509
+ "links": {
510
+ "self": "\/dummy_properties?include=group"
511
+ },
512
+ "meta": {
513
+ "totalItems": 3,
514
+ "itemsPerPage": 3,
515
+ "currentPage": 1
516
+ },
517
+ "data": [
518
+ {
519
+ "id": "/dummy_properties/1",
520
+ "type": "DummyProperty",
521
+ "attributes": {
522
+ "_id": 1,
523
+ "foo": "Foo #1",
524
+ "bar": "Bar #1",
525
+ "baz": "Baz #1"
526
+ },
527
+ "relationships": {
528
+ "group": {
529
+ "data": {
530
+ "type": "DummyGroup",
531
+ "id": "/dummy_groups/1"
532
+ }
533
+ }
534
+ }
535
+ },
536
+ {
537
+ "id": "/dummy_properties/2",
538
+ "type": "DummyProperty",
539
+ "attributes": {
540
+ "_id": 2,
541
+ "foo": "Foo #2",
542
+ "bar": "Bar #2",
543
+ "baz": "Baz #2"
544
+ },
545
+ "relationships": {
546
+ "group": {
547
+ "data": {
548
+ "type": "DummyGroup",
549
+ "id": "/dummy_groups/1"
550
+ }
551
+ }
552
+ }
553
+ },
554
+ {
555
+ "id": "/dummy_properties/3",
556
+ "type": "DummyProperty",
557
+ "attributes": {
558
+ "_id": 3,
559
+ "foo": "Foo #3",
560
+ "bar": "Bar #3",
561
+ "baz": "Baz #3"
562
+ },
563
+ "relationships": {
564
+ "group": {
565
+ "data": {
566
+ "type": "DummyGroup",
567
+ "id": "/dummy_groups/1"
568
+ }
569
+ }
570
+ }
571
+ }
572
+ ],
573
+ "included": [
574
+ {
575
+ "id": "\/dummy_groups\/1",
576
+ "type": "DummyGroup",
577
+ "attributes": {
578
+ "_id": 1,
579
+ "foo": "Foo #shared",
580
+ "bar": "Bar #shared",
581
+ "baz": "Baz #shared"
582
+ }
583
+ }
584
+ ]
585
+ }
586
+ """
You can’t perform that action at this time.
0 commit comments