|
17 | 17 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\CompositeLabel as CompositeLabelDocument;
|
18 | 18 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\CompositePrimitiveItem as CompositePrimitiveItemDocument;
|
19 | 19 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\CompositeRelation as CompositeRelationDocument;
|
| 20 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ConvertedBoolean as ConvertedBoolDocument; |
| 21 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ConvertedDate as ConvertedDateDocument; |
| 22 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ConvertedInteger as ConvertedIntegerDocument; |
| 23 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ConvertedString as ConvertedStringDocument; |
20 | 24 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Customer as CustomerDocument;
|
21 | 25 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Dummy as DummyDocument;
|
22 | 26 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyAggregateOffer as DummyAggregateOfferDocument;
|
|
62 | 66 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositePrimitiveItem;
|
63 | 67 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeRelation;
|
64 | 68 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Container;
|
| 69 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ConvertedBoolean; |
| 70 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ConvertedDate; |
| 71 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ConvertedInteger; |
| 72 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ConvertedString; |
65 | 73 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Customer;
|
66 | 74 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
|
67 | 75 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyAggregateOffer;
|
@@ -164,6 +172,7 @@ public function thereAreDummyObjects(int $nb)
|
164 | 172 | $dummy->setAlias('Alias #'.($nb - $i));
|
165 | 173 | $dummy->setDummy('SomeDummyTest'.$i);
|
166 | 174 | $dummy->setDescription($descriptions[($i - 1) % 2]);
|
| 175 | + $dummy->nameConverted = 'Converted '.$i; |
167 | 176 |
|
168 | 177 | $this->manager->persist($dummy);
|
169 | 178 | }
|
@@ -257,6 +266,7 @@ public function thereAreDummyPropertyObjects(int $nb)
|
257 | 266 | foreach (['foo', 'bar', 'baz'] as $property) {
|
258 | 267 | $dummyProperty->{$property} = $dummyGroup->{$property} = ucfirst($property).' #'.$i;
|
259 | 268 | }
|
| 269 | + $dummyProperty->nameConverted = "NameConverted #$i"; |
260 | 270 |
|
261 | 271 | $dummyProperty->group = $dummyGroup;
|
262 | 272 |
|
@@ -657,6 +667,66 @@ public function thereAreDummyObjectsWithDummyDateAndEmbeddedDummy(int $nb)
|
657 | 667 | $this->manager->flush();
|
658 | 668 | }
|
659 | 669 |
|
| 670 | + /** |
| 671 | + * @Given there are :nb convertedDate objects |
| 672 | + */ |
| 673 | + public function thereAreconvertedDateObjectsWith(int $nb) |
| 674 | + { |
| 675 | + for ($i = 1; $i <= $nb; ++$i) { |
| 676 | + $convertedDate = $this->buildConvertedDate(); |
| 677 | + $convertedDate->nameConverted = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); |
| 678 | + |
| 679 | + $this->manager->persist($convertedDate); |
| 680 | + } |
| 681 | + |
| 682 | + $this->manager->flush(); |
| 683 | + } |
| 684 | + |
| 685 | + /** |
| 686 | + * @Given there are :nb convertedString objects |
| 687 | + */ |
| 688 | + public function thereAreconvertedStringObjectsWith(int $nb) |
| 689 | + { |
| 690 | + for ($i = 1; $i <= $nb; ++$i) { |
| 691 | + $convertedString = $this->buildConvertedString(); |
| 692 | + $convertedString->nameConverted = ($i % 2) ? "name#$i" : null; |
| 693 | + |
| 694 | + $this->manager->persist($convertedString); |
| 695 | + } |
| 696 | + |
| 697 | + $this->manager->flush(); |
| 698 | + } |
| 699 | + |
| 700 | + /** |
| 701 | + * @Given there are :nb convertedBoolean objects |
| 702 | + */ |
| 703 | + public function thereAreconvertedBooleanObjectsWith(int $nb) |
| 704 | + { |
| 705 | + for ($i = 1; $i <= $nb; ++$i) { |
| 706 | + $convertedBoolean = $this->buildConvertedBoolean(); |
| 707 | + $convertedBoolean->nameConverted = (bool) ($i % 2); |
| 708 | + |
| 709 | + $this->manager->persist($convertedBoolean); |
| 710 | + } |
| 711 | + |
| 712 | + $this->manager->flush(); |
| 713 | + } |
| 714 | + |
| 715 | + /** |
| 716 | + * @Given there are :nb convertedInteger objects |
| 717 | + */ |
| 718 | + public function thereAreconvertedIntegerObjectsWith(int $nb) |
| 719 | + { |
| 720 | + for ($i = 1; $i <= $nb; ++$i) { |
| 721 | + $convertedInteger = $this->buildConvertedInteger(); |
| 722 | + $convertedInteger->nameConverted = $i; |
| 723 | + |
| 724 | + $this->manager->persist($convertedInteger); |
| 725 | + } |
| 726 | + |
| 727 | + $this->manager->flush(); |
| 728 | + } |
| 729 | + |
660 | 730 | /**
|
661 | 731 | * @Given there are :nb dummy objects with dummyPrice
|
662 | 732 | */
|
@@ -1264,6 +1334,35 @@ public function thereAreNbDummyDtoCustom($nb)
|
1264 | 1334 | $this->manager->clear();
|
1265 | 1335 | }
|
1266 | 1336 |
|
| 1337 | + /** |
| 1338 | + * @Given there is a order with same customer and receiver |
| 1339 | + */ |
| 1340 | + public function testEagerLoadingNotDuplicateRelation() |
| 1341 | + { |
| 1342 | + $customer = $this->isOrm() ? new Customer() : new CustomerDocument(); |
| 1343 | + $customer->name = 'customer_name'; |
| 1344 | + |
| 1345 | + $address1 = $this->isOrm() ? new Address() : new AddressDocument(); |
| 1346 | + $address1->name = 'foo'; |
| 1347 | + $address2 = $this->isOrm() ? new Address() : new AddressDocument(); |
| 1348 | + $address2->name = 'bar'; |
| 1349 | + |
| 1350 | + $order = $this->isOrm() ? new Order() : new OrderDocument(); |
| 1351 | + $order->recipient = $customer; |
| 1352 | + $order->customer = $customer; |
| 1353 | + |
| 1354 | + $customer->addresses->add($address1); |
| 1355 | + $customer->addresses->add($address2); |
| 1356 | + |
| 1357 | + $this->manager->persist($address1); |
| 1358 | + $this->manager->persist($address2); |
| 1359 | + $this->manager->persist($customer); |
| 1360 | + $this->manager->persist($order); |
| 1361 | + |
| 1362 | + $this->manager->flush(); |
| 1363 | + $this->manager->clear(); |
| 1364 | + } |
| 1365 | + |
1267 | 1366 | private function isOrm(): bool
|
1268 | 1367 | {
|
1269 | 1368 | return null !== $this->schemaTool;
|
@@ -1579,31 +1678,34 @@ private function buildThirdLevel()
|
1579 | 1678 | }
|
1580 | 1679 |
|
1581 | 1680 | /**
|
1582 |
| - * @Given there is a order with same customer and receiver |
| 1681 | + * @return ConvertedDate|ConvertedDateDocument |
1583 | 1682 | */
|
1584 |
| - public function testEagerLoadingNotDuplicateRelation() |
| 1683 | + private function buildConvertedDate() |
1585 | 1684 | {
|
1586 |
| - $customer = $this->isOrm() ? new Customer() : new CustomerDocument(); |
1587 |
| - $customer->name = 'customer_name'; |
1588 |
| - |
1589 |
| - $address1 = $this->isOrm() ? new Address() : new AddressDocument(); |
1590 |
| - $address1->name = 'foo'; |
1591 |
| - $address2 = $this->isOrm() ? new Address() : new AddressDocument(); |
1592 |
| - $address2->name = 'bar'; |
1593 |
| - |
1594 |
| - $order = $this->isOrm() ? new Order() : new OrderDocument(); |
1595 |
| - $order->recipient = $customer; |
1596 |
| - $order->customer = $customer; |
| 1685 | + return $this->isOrm() ? new ConvertedDate() : new ConvertedDateDocument(); |
| 1686 | + } |
1597 | 1687 |
|
1598 |
| - $customer->addresses->add($address1); |
1599 |
| - $customer->addresses->add($address2); |
| 1688 | + /** |
| 1689 | + * @return ConvertedBoolean|ConvertedBoolDocument |
| 1690 | + */ |
| 1691 | + private function buildConvertedBoolean() |
| 1692 | + { |
| 1693 | + return $this->isOrm() ? new ConvertedBoolean() : new ConvertedBoolDocument(); |
| 1694 | + } |
1600 | 1695 |
|
1601 |
| - $this->manager->persist($address1); |
1602 |
| - $this->manager->persist($address2); |
1603 |
| - $this->manager->persist($customer); |
1604 |
| - $this->manager->persist($order); |
| 1696 | + /** |
| 1697 | + * @return ConvertedInteger|ConvertedIntegerDocument |
| 1698 | + */ |
| 1699 | + private function buildConvertedInteger() |
| 1700 | + { |
| 1701 | + return $this->isOrm() ? new ConvertedInteger() : new ConvertedIntegerDocument(); |
| 1702 | + } |
1605 | 1703 |
|
1606 |
| - $this->manager->flush(); |
1607 |
| - $this->manager->clear(); |
| 1704 | + /** |
| 1705 | + * @return ConvertedString|ConvertedStringDocument |
| 1706 | + */ |
| 1707 | + private function buildConvertedString() |
| 1708 | + { |
| 1709 | + return $this->isOrm() ? new ConvertedString() : new ConvertedStringDocument(); |
1608 | 1710 | }
|
1609 | 1711 | }
|
0 commit comments