1 | <?php |
||
2 | |||
3 | declare( strict_types = 1 ); |
||
4 | |||
5 | namespace WMDE\Fundraising\AddressChangeContext\Tests; |
||
6 | |||
7 | use Doctrine\ORM\EntityManager; |
||
8 | |||
9 | /** |
||
10 | * @license GPL-2.0-or-later |
||
11 | */ |
||
12 | class TestEnvironment { |
||
13 | |||
14 | private TestAddressChangeContextFactory $factory; |
||
15 | |||
16 | private function __construct() { |
||
17 | $this->factory = new TestAddressChangeContextFactory( |
||
18 | [ |
||
19 | 'driver' => 'pdo_sqlite', |
||
20 | 'memory' => true, |
||
21 | ] |
||
22 | ); |
||
23 | } |
||
24 | |||
25 | public static function newInstance(): self { |
||
26 | $environment = new self(); |
||
27 | |||
28 | $environment->install(); |
||
29 | |||
30 | return $environment; |
||
31 | } |
||
32 | |||
33 | private function install(): void { |
||
34 | $schema = new SchemaCreator( $this->getEntityManager() ); |
||
35 | |||
36 | try { |
||
37 | $schema->dropSchema(); |
||
38 | } catch ( \Exception $ex ) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
![]() |
|||
39 | } |
||
40 | |||
41 | $schema->createSchema(); |
||
42 | } |
||
43 | |||
44 | public function getEntityManager(): EntityManager { |
||
45 | return $this->factory->getEntityManager(); |
||
46 | } |
||
47 | |||
48 | } |
||
49 |