Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource resolver for inheritance #2714

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions features/bootstrap/DoctrineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyOffer as DummyOfferDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyProduct as DummyProductDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyProperty as DummyPropertyDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\DummyTableInheritanceNotApiResourceChild as DummyTableInheritanceNotApiResourceChildDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\EmbeddableDummy as EmbeddableDummyDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\EmbeddedDummy as EmbeddedDummyDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\FileConfigDummy as FileConfigDummyDocument;
Expand Down Expand Up @@ -74,6 +75,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyOffer;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyProduct;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyProperty;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyTableInheritanceNotApiResourceChild;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\EmbeddableDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\EmbeddedDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy;
Expand Down Expand Up @@ -165,6 +167,17 @@ public function thereAreDummyObjects(int $nb)
$this->manager->flush();
}

/**
* @When some dummy table inheritance data but not api resource child are created
*/
public function someDummyTableInheritanceDataButNotApiResourceChildAreCreated()
{
$dummy = $this->buildDummyTableInheritanceNotApiResourceChild();
$dummy->setName('Foobarbaz inheritance');
$this->manager->persist($dummy);
$this->manager->flush();
}

/**
* @Given there are :nb foo objects with fake names
*/
Expand Down Expand Up @@ -1272,6 +1285,14 @@ private function buildDummy()
return $this->isOrm() ? new Dummy() : new DummyDocument();
}

/**
* @return DummyTableInheritanceNotApiResourceChild|DummyTableInheritanceNotApiResourceChildDocument
*/
private function buildDummyTableInheritanceNotApiResourceChild()
{
return $this->isOrm() ? new DummyTableInheritanceNotApiResourceChild() : new DummyTableInheritanceNotApiResourceChildDocument();
}

/**
* @return DummyAggregateOffer|DummyAggregateOfferDocument
*/
Expand Down Expand Up @@ -1540,4 +1561,44 @@ public function testEagerLoadingNotDuplicateRelation()
$this->manager->flush();
$this->manager->clear();
}

/**
* @Given there are :nb sites with internal owner
*/
public function thereAreSitesWithInternalOwner(int $nb)
{
for ($i = 1; $i <= $nb; ++$i) {
$internalUser = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\InternalUser();
$internalUser->setFirstname('Internal');
$internalUser->setLastname('User');
$internalUser->setEmail('john.doe@example.com');
$internalUser->setInternalId('INT');
$site = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Site();
$site->setTitle('title');
$site->setDescription('description');
$site->setOwner($internalUser);
$this->manager->persist($site);
}
$this->manager->flush();
}

/**
* @Given there are :nb sites with external owner
*/
public function thereAreSitesWithExternalOwner(int $nb)
{
for ($i = 1; $i <= $nb; ++$i) {
$externalUser = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\ExternalUser();
$externalUser->setFirstname('External');
$externalUser->setLastname('User');
$externalUser->setEmail('john.doe@example.com');
$externalUser->setExternalId('EXT');
$site = new \ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Site();
$site->setTitle('title');
$site->setDescription('description');
$site->setOwner($externalUser);
$this->manager->persist($site);
}
$this->manager->flush();
}
}
Loading