Skip to content

Commit

Permalink
Merge pull request #44 from ergebnis/fix/whitespace
Browse files Browse the repository at this point in the history
Fix: Whitespace
  • Loading branch information
localheinz committed Mar 14, 2020
2 parents 6c76035 + 46380b7 commit 3d098fa
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 45 deletions.
6 changes: 3 additions & 3 deletions src/FixtureFactory.php
Expand Up @@ -46,11 +46,8 @@ final class FixtureFactory
public function __construct(ORM\EntityManagerInterface $em)
{
$this->em = $em;

$this->entityDefs = [];

$this->singletons = [];

$this->persist = false;
}

Expand Down Expand Up @@ -88,6 +85,7 @@ public function get($name, array $fieldOverrides = [])
$entityMetadata = $def->getEntityMetadata();

$ent = $entityMetadata->newInstance();

$fieldValues = [];

foreach ($def->getFieldDefs() as $fieldName => $fieldDef) {
Expand Down Expand Up @@ -167,6 +165,7 @@ public function getAsSingleton($name, array $fieldOverrides = [])
if (isset($this->singletons[$name])) {
throw new \Exception("Already a singleton: {$name}");
}

$this->singletons[$name] = $this->get($name, $fieldOverrides);

return $this->singletons[$name];
Expand Down Expand Up @@ -275,6 +274,7 @@ private function createCollectionFrom($array = [])
private function updateCollectionSideOfAssocation($entityBeingCreated, $metadata, $fieldName, $value): void
{
$assoc = $metadata->getAssociationMapping($fieldName);

$inverse = $assoc['inversedBy'];

if ($inverse) {
Expand Down
14 changes: 10 additions & 4 deletions test/Integration/FixtureFactoryTest.php
Expand Up @@ -31,11 +31,14 @@ public function testAutomaticPersistCanBeTurnedOn(): void

$fixtureFactory = new FixtureFactory($entityManager);

$fixtureFactory->defineEntity(Fixture\FixtureFactory\Entity\Spaceship::class, ['name' => 'Zeta']);
$fixtureFactory->defineEntity(Fixture\FixtureFactory\Entity\Spaceship::class, [
'name' => 'Zeta',
]);

$fixtureFactory->persistOnGet();

$ss = $fixtureFactory->get(Fixture\FixtureFactory\Entity\Spaceship::class);

$entityManager->flush();

self::assertNotNull($ss->getId());
Expand All @@ -48,18 +51,21 @@ public function testDoesNotPersistByDefault(): void

$fixtureFactory = new FixtureFactory($entityManager);

$fixtureFactory->defineEntity(Fixture\FixtureFactory\Entity\Spaceship::class, ['name' => 'Zeta']);
$fixtureFactory->defineEntity(Fixture\FixtureFactory\Entity\Spaceship::class, [
'name' => 'Zeta',
]);

$ss = $fixtureFactory->get(Fixture\FixtureFactory\Entity\Spaceship::class);

$entityManager->flush();

self::assertNull($ss->getId());
$q = $entityManager
->createQueryBuilder()

$q = $entityManager->createQueryBuilder()
->select('ss')
->from(Fixture\FixtureFactory\Entity\Spaceship::class, 'ss')
->getQuery();

self::assertEmpty($q->getResult());
}

Expand Down

0 comments on commit 3d098fa

Please sign in to comment.