Passed
Pull Request — master (#21)
by GIT
08:43 queued 44s
created

ServicesFactoryTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 88
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SMW\ApprovedRevs\Tests;
4
5
use SMW\ApprovedRevs\ServicesFactory;
6
7
/**
8
 * @covers \SMW\ApprovedRevs\ServicesFactory
9
 * @group semantic-approved-revs
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class ServicesFactoryTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			ServicesFactory::class,
22
			new ServicesFactory()
23
		);
24
	}
25
26
	public function testGetConnection( ) {
27
28
		$connection = $this->getMockBuilder( '\DatabaseBase' )
29
			->disableOriginalConstructor()
30
			->getMock();
31
32
		$instance = new ServicesFactory();
33
34
		$instance->setConnection(
35
			$connection
36
		);
37
38
		$this->assertSame(
39
			$connection,
40
			$instance->getConnection()
41
		);
42
	}
43
44
	public function testCanConstructApprovedRevsFacade( ) {
45
46
		$instance = new ServicesFactory();
47
48
		$this->assertInstanceOf(
49
			'\SMW\ApprovedRevs\ApprovedRevsFacade',
50
			$instance->newApprovedRevsFacade()
51
		);
52
	}
53
54
	public function testCanConstructDatabaseLogReader() {
55
56
		$connection = $this->getMockBuilder( '\DatabaseBase' )
57
			->disableOriginalConstructor()
58
			->getMock();
59
60
		$appFactory = new ServicesFactory();
61
		$appFactory->setConnection( $connection );
62
63
		$dbLogReader = $appFactory->newDatabaseLogReader( null );
64
		$this->assertNull( $dbLogReader->getStatusOfLogEntry() );
65
	}
66
67
	/**
68
	 * @dataProvider propertyAnnotatorsProvider
69
	 */
70
	public function testCanConstructPropertyAnnotators( $name, $instanceOf ) {
71
72
		$instance = new ServicesFactory();
73
74
		$this->assertInstanceOf(
75
			$instanceOf,
76
			call_user_func_array( [ $instance, $name ], [] )
77
		);
78
	}
79
80
	public function propertyAnnotatorsProvider() {
81
82
		yield [
83
			'newApprovedByPropertyAnnotator',
84
			'\SMW\ApprovedRevs\PropertyAnnotators\ApprovedByPropertyAnnotator'
85
		];
86
87
		yield [
88
			'newApprovedStatusPropertyAnnotator',
89
			'\SMW\ApprovedRevs\PropertyAnnotators\ApprovedStatusPropertyAnnotator'
90
		];
91
92
		yield [
93
			'newApprovedDatePropertyAnnotator',
94
			'\SMW\ApprovedRevs\PropertyAnnotators\ApprovedDatePropertyAnnotator'
95
		];
96
97
		yield [
98
			'newApprovedRevPropertyAnnotator',
99
			'\SMW\ApprovedRevs\PropertyAnnotators\ApprovedRevPropertyAnnotator'
100
		];
101
	}
102
103
}
104