11<?php
22
3+ declare (strict_types=1 );
4+
35namespace ApiSkeletonsTest \Doctrine \GraphQL ;
46
57use DateTime ;
810use Doctrine \ORM \Tools \SchemaTool ;
911use Doctrine \ORM \Tools \Setup ;
1012use PHPUnit \Framework \TestCase ;
13+ use Ramsey \Uuid \Uuid ;
14+
15+ use function date ;
1116
1217require_once __DIR__ . '/../vendor/autoload.php ' ;
1318
@@ -19,18 +24,18 @@ public function setUp(): void
1924 {
2025 // Create a simple "default" Doctrine ORM configuration for Annotations
2126 $ isDevMode = true ;
22- $ config = Setup::createAttributeMetadataConfiguration ([__DIR__ . '/Entity ' ], $ isDevMode );
27+ $ config = Setup::createAttributeMetadataConfiguration ([__DIR__ . '/Entity ' ], $ isDevMode );
2328
2429 // database configuration parameters
25- $ conn = array (
30+ $ conn = [
2631 'driver ' => 'pdo_sqlite ' ,
2732 'memory ' => true ,
28- ) ;
33+ ] ;
2934
3035 // obtaining the entity manager
3136 $ this ->entityManager = EntityManager::create ($ conn , $ config );
32- $ tool = new SchemaTool ($ this ->entityManager );
33- $ res = $ tool ->createSchema ($ this ->entityManager ->getMetadataFactory ()->getAllMetadata ());
37+ $ tool = new SchemaTool ($ this ->entityManager );
38+ $ res = $ tool ->createSchema ($ this ->entityManager ->getMetadataFactory ()->getAllMetadata ());
3439
3540 $ this ->populateData ();
3641 }
@@ -40,7 +45,7 @@ protected function getEntityManager(): EntityManager
4045 return $ this ->entityManager ;
4146 }
4247
43- protected function populateData ()
48+ protected function populateData (): void
4449 {
4550 $ users = [
4651 [
@@ -51,7 +56,7 @@ protected function populateData()
5156 [
5257 'name ' => 'User two ' ,
5358 'email ' => 'userTwo@gmail.com ' ,
54- 'password ' => 'fdsa '
59+ 'password ' => 'fdsa ' ,
5560 ],
5661 ];
5762
@@ -66,17 +71,17 @@ protected function populateData()
6671 . 'Walker; see info file and pub comments for notes; '
6772 . 'possibly "click track" audible on a couple tracks ' ,
6873 'DSBD > 1C > DAT; Seeded to etree by Dan Stephens ' ,
69- ]
74+ ],
7075 ],
7176 '1969-11-08T00:00:00+00:00 ' => [
7277 'venue ' => 'Fillmore Auditorium ' ,
7378 'city ' => 'San Francisco ' ,
7479 'state ' => 'California ' ,
7580 ],
7681 '1977-05-08T00:00:00+00:00 ' => [
77- 'venue ' => 'Barton Hall, Cornell University ' ,
78- 'city ' => 'Ithaca ' ,
79- 'state ' => 'New York ' ,
82+ 'venue ' => 'Barton Hall, Cornell University ' ,
83+ 'city ' => 'Ithaca ' ,
84+ 'state ' => 'New York ' ,
8085 ],
8186 '1995-07-09T00:00:00+00:00 ' => [
8287 'venue ' => 'Soldier Field ' ,
@@ -94,9 +99,7 @@ protected function populateData()
9499 'venue ' => 'E Center ' ,
95100 'city ' => 'West Valley City ' ,
96101 'state ' => 'Utah ' ,
97- 'recordings ' => [
98- 'AKG480 > Aerco preamp > SBM-1 ' ,
99- ],
102+ 'recordings ' => ['AKG480 > Aerco preamp > SBM-1 ' ],
100103 ],
101104 '1999-12-31T00:00:00+00:00 ' => [
102105 'venue ' => null ,
@@ -135,14 +138,15 @@ protected function populateData()
135138 ->setArtist ($ artist );
136139 $ this ->entityManager ->persist ($ performance );
137140
138- if (isset ($ location ['recordings ' ])) {
139- foreach ($ location ['recordings ' ] as $ source ) {
140- $ recording = (new Entity \Recording ())
141- ->setSource ($ source )
142- ->setPerformance ($ performance );
143- $ this ->entityManager ->persist ($ recording );
144- }
141+ if (! isset ($ location ['recordings ' ])) {
142+ continue ;
143+ }
145144
145+ foreach ($ location ['recordings ' ] as $ source ) {
146+ $ recording = (new Entity \Recording ())
147+ ->setSource ($ source )
148+ ->setPerformance ($ performance );
149+ $ this ->entityManager ->persist ($ recording );
146150 }
147151 }
148152 }
@@ -165,15 +169,13 @@ protected function populateData()
165169 ->setTestDateTimeTZImmutable ($ immutableDateTime )
166170 ->setTestDecimal (314.15 )
167171 ->setTestJson (['to ' => 'json ' , ['test ' => 'testing ' ]])
168- ->setTestSimpleArray (['one ' ,'two ' ,'three ' ])
172+ ->setTestSimpleArray (['one ' , 'two ' , 'three ' ])
169173 ->setTestSmallInt (123 )
170174 ->setTestTime (new DateTime ('2022-08-07T20:10:15.123456 ' ))
171175 ->setTestTimeImmutable ($ immutableDateTime )
172- ->setTestGuid (\Ramsey \Uuid \Uuid::uuid4 ())
173- ;
176+ ->setTestGuid (Uuid::uuid4 ()->toString ());
174177 $ this ->entityManager ->persist ($ typeTest );
175178
176-
177179 $ this ->entityManager ->flush ();
178180 $ this ->entityManager ->clear ();
179181 }
0 commit comments