forked from API-Skeletons/doctrine-orm-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af044c5
commit c1847e9
Showing
33 changed files
with
488 additions
and
725 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiSkeletonsTest\Doctrine\GraphQL; | ||
|
||
use DateTime; | ||
|
@@ -8,6 +10,9 @@ | |
use Doctrine\ORM\Tools\SchemaTool; | ||
use Doctrine\ORM\Tools\Setup; | ||
use PHPUnit\Framework\TestCase; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
use function date; | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
|
@@ -19,18 +24,18 @@ public function setUp(): void | |
{ | ||
// Create a simple "default" Doctrine ORM configuration for Annotations | ||
$isDevMode = true; | ||
$config = Setup::createAttributeMetadataConfiguration([__DIR__ . '/Entity'], $isDevMode); | ||
$config = Setup::createAttributeMetadataConfiguration([__DIR__ . '/Entity'], $isDevMode); | ||
|
||
// database configuration parameters | ||
$conn = array( | ||
$conn = [ | ||
'driver' => 'pdo_sqlite', | ||
'memory' => true, | ||
); | ||
]; | ||
|
||
// obtaining the entity manager | ||
$this->entityManager = EntityManager::create($conn, $config); | ||
$tool = new SchemaTool($this->entityManager); | ||
$res = $tool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata()); | ||
$tool = new SchemaTool($this->entityManager); | ||
$res = $tool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata()); | ||
|
||
$this->populateData(); | ||
} | ||
|
@@ -40,7 +45,7 @@ protected function getEntityManager(): EntityManager | |
return $this->entityManager; | ||
} | ||
|
||
protected function populateData() | ||
protected function populateData(): void | ||
{ | ||
$users = [ | ||
[ | ||
|
@@ -51,7 +56,7 @@ protected function populateData() | |
[ | ||
'name' => 'User two', | ||
'email' => '[email protected]', | ||
'password' => 'fdsa' | ||
'password' => 'fdsa', | ||
], | ||
]; | ||
|
||
|
@@ -66,17 +71,17 @@ protected function populateData() | |
. 'Walker; see info file and pub comments for notes; ' | ||
. 'possibly "click track" audible on a couple tracks', | ||
'DSBD > 1C > DAT; Seeded to etree by Dan Stephens', | ||
] | ||
], | ||
], | ||
'1969-11-08T00:00:00+00:00' => [ | ||
'venue' => 'Fillmore Auditorium', | ||
'city' => 'San Francisco', | ||
'state' => 'California', | ||
], | ||
'1977-05-08T00:00:00+00:00' => [ | ||
'venue' => 'Barton Hall, Cornell University', | ||
'city' => 'Ithaca', | ||
'state' => 'New York', | ||
'venue' => 'Barton Hall, Cornell University', | ||
'city' => 'Ithaca', | ||
'state' => 'New York', | ||
], | ||
'1995-07-09T00:00:00+00:00' => [ | ||
'venue' => 'Soldier Field', | ||
|
@@ -94,9 +99,7 @@ protected function populateData() | |
'venue' => 'E Center', | ||
'city' => 'West Valley City', | ||
'state' => 'Utah', | ||
'recordings' => [ | ||
'AKG480 > Aerco preamp > SBM-1', | ||
], | ||
'recordings' => ['AKG480 > Aerco preamp > SBM-1'], | ||
], | ||
'1999-12-31T00:00:00+00:00' => [ | ||
'venue' => null, | ||
|
@@ -135,14 +138,15 @@ protected function populateData() | |
->setArtist($artist); | ||
$this->entityManager->persist($performance); | ||
|
||
if (isset($location['recordings'])) { | ||
foreach ($location['recordings'] as $source) { | ||
$recording = (new Entity\Recording()) | ||
->setSource($source) | ||
->setPerformance($performance); | ||
$this->entityManager->persist($recording); | ||
} | ||
if (! isset($location['recordings'])) { | ||
continue; | ||
} | ||
|
||
foreach ($location['recordings'] as $source) { | ||
$recording = (new Entity\Recording()) | ||
->setSource($source) | ||
->setPerformance($performance); | ||
$this->entityManager->persist($recording); | ||
} | ||
} | ||
} | ||
|
@@ -165,15 +169,13 @@ protected function populateData() | |
->setTestDateTimeTZImmutable($immutableDateTime) | ||
->setTestDecimal(314.15) | ||
->setTestJson(['to' => 'json', ['test' => 'testing']]) | ||
->setTestSimpleArray(['one','two','three']) | ||
->setTestSimpleArray(['one', 'two', 'three']) | ||
->setTestSmallInt(123) | ||
->setTestTime(new DateTime('2022-08-07T20:10:15.123456')) | ||
->setTestTimeImmutable($immutableDateTime) | ||
->setTestGuid(\Ramsey\Uuid\Uuid::uuid4()) | ||
; | ||
->setTestGuid(Uuid::uuid4()->toString()); | ||
$this->entityManager->persist($typeTest); | ||
|
||
|
||
$this->entityManager->flush(); | ||
$this->entityManager->clear(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.