SetupTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRun() 0 27 2
A newExtension() 0 3 1
1
<?php
2
3
namespace Tests\Unit\SubPageList;
4
5
use PHPUnit\Framework\TestCase;
6
use SubPageList\Setup;
7
8
/**
9
 * @covers \SubPageList\Setup
10
 *
11
 * @group SubPageList
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class SetupTest extends TestCase {
17
18
	public function testRun() {
19
		$extension = $this->newExtension();
20
21
		$hookLists = [
22
			'ParserFirstCallInit' => [],
23
			'ArticleInsertComplete' => [],
24
			'ArticleDeleteComplete' => [],
25
			'TitleMoveComplete' => [],
26
			'UnitTestsList' => [],
27
		];
28
29
		$setup = new Setup(
30
			$extension,
31
			$hookLists,
32
			__DIR__ . '/..'
33
		);
34
35
		$setup->run();
36
37
		foreach ( $hookLists as $hookName => $hookList ) {
38
			$this->assertEquals( 1, count( $hookList ), "one hook handler need to be added to '$hookName'" );
39
40
			$hook = reset( $hookList );
41
42
			$this->assertInternalType( 'callable', $hook );
43
		}
44
	}
45
46
	private function newExtension() {
47
		return new \SubPageList\Extension( \SubPageList\Settings::newFromGlobals( $GLOBALS ) );
48
	}
49
50
}
51