TestEnvironment::newInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests\Queryr\Replicator\Integration;
4
5
use Doctrine\DBAL\DriverManager;
6
use Queryr\Replicator\ServiceFactory;
7
8
/**
9
 * @licence GNU GPL v2+
10
 * @author Jeroen De Dauw < [email protected] >
11
 */
12
class TestEnvironment {
13
14
	public static function newInstance() {
15
		return new self();
16
	}
17
18
	/**
19
	 * @var ServiceFactory
20
	 */
21
	private $factory;
22
23
	private function __construct() {
24
		$connection = DriverManager::getConnection( array(
25
			'driver' => 'pdo_sqlite',
26
			'memory' => true,
27
		) );
28
29
		$this->factory = ServiceFactory::newFromConnection( $connection );
30
31
		$this->factory->newEntityStoreInstaller()->install();
32
33
		if ( defined( 'WIKIBASE_QUERYENGINE_VERSION' ) ) {
34
			$this->factory->newQueryEngineInstaller()->install();
35
		}
36
37
		$this->factory->newTermStoreInstaller()->install();
38
	}
39
40
	/**
41
	 * @return ServiceFactory
42
	 */
43
	public function getFactory(): ServiceFactory {
44
		return $this->factory;
45
	}
46
47
}
48