1 | <?php |
||
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 |