|
44 | 44 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Person as PersonDocument;
|
45 | 45 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\PersonToPet as PersonToPetDocument;
|
46 | 46 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Pet as PetDocument;
|
| 47 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Product as ProductDocument; |
47 | 48 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Question as QuestionDocument;
|
48 | 49 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\RelatedDummy as RelatedDummyDocument;
|
49 | 50 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\RelatedOwnedDummy as RelatedOwnedDummyDocument;
|
50 | 51 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\RelatedOwningDummy as RelatedOwningDummyDocument;
|
51 | 52 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\RelatedToDummyFriend as RelatedToDummyFriendDocument;
|
52 | 53 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\RelationEmbedder as RelationEmbedderDocument;
|
53 | 54 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\SecuredDummy as SecuredDummyDocument;
|
| 55 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Taxon as TaxonDocument; |
54 | 56 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ThirdLevel as ThirdLevelDocument;
|
55 | 57 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\User as UserDocument;
|
56 | 58 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Address;
|
|
78 | 80 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyTableInheritanceNotApiResourceChild;
|
79 | 81 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\EmbeddableDummy;
|
80 | 82 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\EmbeddedDummy;
|
| 83 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ExternalUser; |
81 | 84 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy;
|
82 | 85 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Foo;
|
83 | 86 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FooDummy;
|
84 | 87 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FourthLevel;
|
85 | 88 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Greeting;
|
| 89 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\InternalUser; |
86 | 90 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\MaxDepthDummy;
|
87 | 91 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Node;
|
88 | 92 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Order;
|
89 | 93 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Person;
|
90 | 94 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\PersonToPet;
|
91 | 95 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Pet;
|
| 96 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Product; |
92 | 97 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Question;
|
93 | 98 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RamseyUuidDummy;
|
94 | 99 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
|
|
97 | 102 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedToDummyFriend;
|
98 | 103 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelationEmbedder;
|
99 | 104 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\SecuredDummy;
|
| 105 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Site; |
| 106 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Taxon; |
100 | 107 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ThirdLevel;
|
101 | 108 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\User;
|
102 | 109 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\UuidIdentifierDummy;
|
103 | 110 | use Behat\Behat\Context\Context;
|
| 111 | +use Behat\Gherkin\Node\PyStringNode; |
104 | 112 | use Doctrine\Common\Persistence\ManagerRegistry;
|
105 | 113 | use Doctrine\ODM\MongoDB\DocumentManager;
|
106 | 114 | use Doctrine\ORM\EntityManagerInterface;
|
@@ -1227,6 +1235,108 @@ public function thereAreNbDummyDtoCustom($nb)
|
1227 | 1235 | $this->manager->clear();
|
1228 | 1236 | }
|
1229 | 1237 |
|
| 1238 | + /** |
| 1239 | + * @Given there is an order with same customer and recipient |
| 1240 | + */ |
| 1241 | + public function thereIsAnOrderWithSameCustomerAndRecipient() |
| 1242 | + { |
| 1243 | + $customer = $this->isOrm() ? new Customer() : new CustomerDocument(); |
| 1244 | + $customer->name = 'customer_name'; |
| 1245 | + |
| 1246 | + $address1 = $this->isOrm() ? new Address() : new AddressDocument(); |
| 1247 | + $address1->name = 'foo'; |
| 1248 | + $address2 = $this->isOrm() ? new Address() : new AddressDocument(); |
| 1249 | + $address2->name = 'bar'; |
| 1250 | + |
| 1251 | + $order = $this->isOrm() ? new Order() : new OrderDocument(); |
| 1252 | + $order->recipient = $customer; |
| 1253 | + $order->customer = $customer; |
| 1254 | + |
| 1255 | + $customer->addresses->add($address1); |
| 1256 | + $customer->addresses->add($address2); |
| 1257 | + |
| 1258 | + $this->manager->persist($address1); |
| 1259 | + $this->manager->persist($address2); |
| 1260 | + $this->manager->persist($customer); |
| 1261 | + $this->manager->persist($order); |
| 1262 | + |
| 1263 | + $this->manager->flush(); |
| 1264 | + $this->manager->clear(); |
| 1265 | + } |
| 1266 | + |
| 1267 | + /** |
| 1268 | + * @Given there are :nb sites with internal owner |
| 1269 | + */ |
| 1270 | + public function thereAreSitesWithInternalOwner(int $nb) |
| 1271 | + { |
| 1272 | + for ($i = 1; $i <= $nb; ++$i) { |
| 1273 | + $internalUser = new InternalUser(); |
| 1274 | + $internalUser->setFirstname('Internal'); |
| 1275 | + $internalUser->setLastname('User'); |
| 1276 | + $internalUser-> setEmail( '[email protected]'); |
| 1277 | + $internalUser->setInternalId('INT'); |
| 1278 | + $site = new Site(); |
| 1279 | + $site->setTitle('title'); |
| 1280 | + $site->setDescription('description'); |
| 1281 | + $site->setOwner($internalUser); |
| 1282 | + $this->manager->persist($site); |
| 1283 | + } |
| 1284 | + $this->manager->flush(); |
| 1285 | + } |
| 1286 | + |
| 1287 | + /** |
| 1288 | + * @Given there are :nb sites with external owner |
| 1289 | + */ |
| 1290 | + public function thereAreSitesWithExternalOwner(int $nb) |
| 1291 | + { |
| 1292 | + for ($i = 1; $i <= $nb; ++$i) { |
| 1293 | + $externalUser = new ExternalUser(); |
| 1294 | + $externalUser->setFirstname('External'); |
| 1295 | + $externalUser->setLastname('User'); |
| 1296 | + $externalUser-> setEmail( '[email protected]'); |
| 1297 | + $externalUser->setExternalId('EXT'); |
| 1298 | + $site = new Site(); |
| 1299 | + $site->setTitle('title'); |
| 1300 | + $site->setDescription('description'); |
| 1301 | + $site->setOwner($externalUser); |
| 1302 | + $this->manager->persist($site); |
| 1303 | + } |
| 1304 | + $this->manager->flush(); |
| 1305 | + } |
| 1306 | + |
| 1307 | + /** |
| 1308 | + * @Given there is the following taxon: |
| 1309 | + */ |
| 1310 | + public function thereIsTheFollowingTaxon(PyStringNode $dataNode): void |
| 1311 | + { |
| 1312 | + $data = json_decode((string) $dataNode, true); |
| 1313 | + |
| 1314 | + $taxon = $this->isOrm() ? new Taxon() : new TaxonDocument(); |
| 1315 | + $taxon->setCode($data['code']); |
| 1316 | + $this->manager->persist($taxon); |
| 1317 | + |
| 1318 | + $this->manager->flush(); |
| 1319 | + } |
| 1320 | + |
| 1321 | + /** |
| 1322 | + * @Given there is the following product: |
| 1323 | + */ |
| 1324 | + public function thereIsTheFollowingProduct(PyStringNode $dataNode): void |
| 1325 | + { |
| 1326 | + $data = json_decode((string) $dataNode, true); |
| 1327 | + |
| 1328 | + $product = $this->isOrm() ? new Product() : new ProductDocument(); |
| 1329 | + $product->setCode($data['code']); |
| 1330 | + if (isset($data['mainTaxon'])) { |
| 1331 | + $mainTaxonId = (int) str_replace('/taxons/', '', $data['mainTaxon']); |
| 1332 | + $mainTaxon = $this->manager->getRepository($this->isOrm() ? Taxon::class : TaxonDocument::class)->find($mainTaxonId); |
| 1333 | + $product->setMainTaxon($mainTaxon); |
| 1334 | + } |
| 1335 | + $this->manager->persist($product); |
| 1336 | + |
| 1337 | + $this->manager->flush(); |
| 1338 | + } |
| 1339 | + |
1230 | 1340 | private function isOrm(): bool
|
1231 | 1341 | {
|
1232 | 1342 | return null !== $this->schemaTool;
|
@@ -1532,73 +1642,4 @@ private function buildThirdLevel()
|
1532 | 1642 | {
|
1533 | 1643 | return $this->isOrm() ? new ThirdLevel() : new ThirdLevelDocument();
|
1534 | 1644 | }
|
1535 |
| - |
1536 |
| - /** |
1537 |
| - * @Given there is a order with same customer and receiver |
1538 |
| - */ |
1539 |
| - public function testEagerLoadingNotDuplicateRelation() |
1540 |
| - { |
1541 |
| - $customer = $this->isOrm() ? new Customer() : new CustomerDocument(); |
1542 |
| - $customer->name = 'customer_name'; |
1543 |
| - |
1544 |
| - $address1 = $this->isOrm() ? new Address() : new AddressDocument(); |
1545 |
| - $address1->name = 'foo'; |
1546 |
| - $address2 = $this->isOrm() ? new Address() : new AddressDocument(); |
1547 |
| - $address2->name = 'bar'; |
1548 |
| - |
1549 |
| - $order = $this->isOrm() ? new Order() : new OrderDocument(); |
1550 |
| - $order->recipient = $customer; |
1551 |
| - $order->customer = $customer; |
1552 |
| - |
1553 |
| - $customer->addresses->add($address1); |
1554 |
| - $customer->addresses->add($address2); |
1555 |
| - |
1556 |
| - $this->manager->persist($address1); |
1557 |
| - $this->manager->persist($address2); |
1558 |
| - $this->manager->persist($customer); |
1559 |
| - $this->manager->persist($order); |
1560 |
| - |
1561 |
| - $this->manager->flush(); |
1562 |
| - $this->manager->clear(); |
1563 |
| - } |
1564 |
| - |
1565 |
| - /** |
1566 |
| - * @Given there are :nb sites with internal owner |
1567 |
| - */ |
1568 |
| - public function thereAreSitesWithInternalOwner(int $nb) |
1569 |
| - { |
1570 |
| - for ($i = 1; $i <= $nb; ++$i) { |
1571 |
| - $internalUser = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\InternalUser(); |
1572 |
| - $internalUser->setFirstname('Internal'); |
1573 |
| - $internalUser->setLastname('User'); |
1574 |
| - $internalUser-> setEmail( '[email protected]'); |
1575 |
| - $internalUser->setInternalId('INT'); |
1576 |
| - $site = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Site(); |
1577 |
| - $site->setTitle('title'); |
1578 |
| - $site->setDescription('description'); |
1579 |
| - $site->setOwner($internalUser); |
1580 |
| - $this->manager->persist($site); |
1581 |
| - } |
1582 |
| - $this->manager->flush(); |
1583 |
| - } |
1584 |
| - |
1585 |
| - /** |
1586 |
| - * @Given there are :nb sites with external owner |
1587 |
| - */ |
1588 |
| - public function thereAreSitesWithExternalOwner(int $nb) |
1589 |
| - { |
1590 |
| - for ($i = 1; $i <= $nb; ++$i) { |
1591 |
| - $externalUser = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ExternalUser(); |
1592 |
| - $externalUser->setFirstname('External'); |
1593 |
| - $externalUser->setLastname('User'); |
1594 |
| - $externalUser-> setEmail( '[email protected]'); |
1595 |
| - $externalUser->setExternalId('EXT'); |
1596 |
| - $site = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Site(); |
1597 |
| - $site->setTitle('title'); |
1598 |
| - $site->setDescription('description'); |
1599 |
| - $site->setOwner($externalUser); |
1600 |
| - $this->manager->persist($site); |
1601 |
| - } |
1602 |
| - $this->manager->flush(); |
1603 |
| - } |
1604 | 1645 | }
|
0 commit comments