|
13 | 13 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeLabel;
|
14 | 14 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeRelation;
|
15 | 15 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
|
| 16 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyCar; |
| 17 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyCarColor; |
| 18 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyFriend; |
16 | 19 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy;
|
17 | 20 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
|
| 21 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedToDummyFriend; |
18 | 22 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelationEmbedder;
|
19 | 23 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\UuidIdentifierDummy;
|
20 | 24 | use Behat\Behat\Context\Context;
|
@@ -135,18 +139,21 @@ public function thereIsDummyObjectsWithRelatedDummy($nb)
|
135 | 139 | }
|
136 | 140 |
|
137 | 141 | /**
|
138 |
| - * @Given there is :nb dummy objects with relatedDummies |
| 142 | + * @Given there is :nb dummy objects having each :nbrelated relatedDummies |
139 | 143 | */
|
140 |
| - public function thereIsDummyObjectsWithRelatedDummies($nb) |
| 144 | + public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated) |
141 | 145 | {
|
142 | 146 | for ($i = 1; $i <= $nb; ++$i) {
|
143 |
| - $relatedDummy = new RelatedDummy(); |
144 |
| - $relatedDummy->setName('RelatedDummy #'.$i); |
145 |
| - |
146 | 147 | $dummy = new Dummy();
|
147 | 148 | $dummy->setName('Dummy #'.$i);
|
148 | 149 | $dummy->setAlias('Alias #'.($nb - $i));
|
149 |
| - $dummy->addRelatedDummy($relatedDummy); |
| 150 | + |
| 151 | + for ($j = 1; $j <= $nbrelated; ++$j) { |
| 152 | + $relatedDummy = new RelatedDummy(); |
| 153 | + $relatedDummy->setName('RelatedDummy'.$j.$i); |
| 154 | + $this->manager->persist($relatedDummy); |
| 155 | + $dummy->addRelatedDummy($relatedDummy); |
| 156 | + } |
150 | 157 |
|
151 | 158 | $this->manager->persist($relatedDummy);
|
152 | 159 | $this->manager->persist($dummy);
|
@@ -319,4 +326,60 @@ public function thereIsAFileConfigDummyObject()
|
319 | 326 | $this->manager->persist($fileConfigDummy);
|
320 | 327 | $this->manager->flush();
|
321 | 328 | }
|
| 329 | + |
| 330 | + /** |
| 331 | + * @Given there is a DummyCar entity with related colors |
| 332 | + */ |
| 333 | + public function thereIsAFooEntityWithRelatedBars() |
| 334 | + { |
| 335 | + $foo = new DummyCar(); |
| 336 | + $this->manager->persist($foo); |
| 337 | + |
| 338 | + $bar1 = new DummyCarColor(); |
| 339 | + $bar1->setProp('red'); |
| 340 | + $bar1->setCar($foo); |
| 341 | + $this->manager->persist($bar1); |
| 342 | + |
| 343 | + $bar2 = new DummyCarColor(); |
| 344 | + $bar2->setProp('blue'); |
| 345 | + $bar2->setCar($foo); |
| 346 | + $this->manager->persist($bar2); |
| 347 | + |
| 348 | + $foo->setColors([$bar1, $bar2]); |
| 349 | + $this->manager->persist($foo); |
| 350 | + |
| 351 | + $this->manager->flush(); |
| 352 | + } |
| 353 | + |
| 354 | + /** |
| 355 | + * @Given there is a RelatedDummy with :nb friends |
| 356 | + */ |
| 357 | + public function thereIsARelatedDummyWithFriends($nb) |
| 358 | + { |
| 359 | + $relatedDummy = new RelatedDummy(); |
| 360 | + $relatedDummy->setName('RelatedDummy with friends'); |
| 361 | + $this->manager->persist($relatedDummy); |
| 362 | + |
| 363 | + for ($i = 1; $i <= $nb; ++$i) { |
| 364 | + $friend = new DummyFriend(); |
| 365 | + $friend->setName('Friend-'.$i); |
| 366 | + |
| 367 | + $this->manager->persist($friend); |
| 368 | + |
| 369 | + $relation = new RelatedToDummyFriend(); |
| 370 | + $relation->setName('Relation-'.$i); |
| 371 | + $relation->setDummyFriend($friend); |
| 372 | + $relation->setRelatedDummy($relatedDummy); |
| 373 | + |
| 374 | + $relatedDummy->addRelatedToDummyFriend($relation); |
| 375 | + |
| 376 | + $this->manager->persist($relation); |
| 377 | + } |
| 378 | + |
| 379 | + $relatedDummy2 = new RelatedDummy(); |
| 380 | + $relatedDummy2->setName('RelatedDummy without friends'); |
| 381 | + $this->manager->persist($relatedDummy2); |
| 382 | + |
| 383 | + $this->manager->flush(); |
| 384 | + } |
322 | 385 | }
|
0 commit comments