TestEnvironment::getFactory()   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\TermStore;
4
5
use Doctrine\DBAL\DriverManager;
6
use Queryr\TermStore\TermStoreConfig;
7
use Queryr\TermStore\TermStoreFactory;
8
9
/**
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class TestEnvironment {
14
15
	public static function newInstance() {
16
		$instance = new self();
17
18
		$instance->getFactory()->newTermStoreInstaller()->install();
19
20
		return $instance;
21
	}
22
23
	public static function newInstanceWithoutTables() {
24
		return new self();
25
	}
26
27
	/**
28
	 * @var TermStoreFactory
29
	 */
30
	private $factory;
31
32
	private function __construct() {
33
		$connection = DriverManager::getConnection( array(
34
				'driver' => 'pdo_sqlite',
35
				'memory' => true,
36
		) );
37
38
		$config = new TermStoreConfig( 'ts_' );
39
		$this->factory = new TermStoreFactory( $connection, $config );
40
	}
41
42
	public function getFactory() {
43
		return $this->factory;
44
	}
45
46
}