LazyDBConnectionProviderTest::testConstructor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\Unit\SubPageList;
4
5
use PHPUnit\Framework\TestCase;
6
use SubPageList\DBConnectionProvider;
7
use SubPageList\LazyDBConnectionProvider;
8
9
/**
10
 * @covers \SubPageList\LazyDBConnectionProvider
11
 *
12
 * @group SubPageList
13
 *
14
 * @licence GNU GPL v2+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class LazyDBConnectionProviderTest extends TestCase {
18
19
	/**
20
	 * @dataProvider constructorProvider
21
	 *
22
	 * @param int $dbId
23
	 */
24
	public function testConstructor( $dbId ) {
25
		new LazyDBConnectionProvider( $dbId );
26
27
		$this->assertTrue( true );
28
	}
29
30
	public function constructorProvider() {
31
		$argLists = [
32
			[ DB_MASTER ],
33
			[ DB_REPLICA ],
34
		];
35
36
		return $argLists;
37
	}
38
39
	/**
40
	 * @dataProvider instanceProvider
41
	 *
42
	 * @param DBConnectionProvider $connProvider
43
	 */
44
	public function testGetConnection( DBConnectionProvider $connProvider ) {
45
		$connection = $connProvider->getConnection();
46
47
		$this->assertInstanceOf( 'DatabaseBase', $connection );
48
49
		$this->assertTrue( $connection === $connProvider->getConnection() );
50
51
		$connProvider->releaseConnection();
52
53
		$this->assertInstanceOf( 'DatabaseBase', $connProvider->getConnection() );
54
	}
55
56
	public function instanceProvider() {
57
		$argLists = [];
58
59
		$argLists[] = [ new LazyDBConnectionProvider( DB_MASTER ) ];
60
		$argLists[] = [ new LazyDBConnectionProvider( DB_REPLICA ) ];
61
62
		return $argLists;
63
	}
64
65
}
66