HookRegistryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 7 1
B testRegister() 0 29 1
A assertHookIsExcutable() 0 8 2
1
<?php
2
3
namespace SES\Tests;
4
5
use SES\HookRegistry;
6
7
/**
8
 * @covers \SES\HookRegistry
9
 *
10
 * @group semantic-signup
11
 *
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class HookRegistryTest extends \PHPUnit_Framework_TestCase {
18
19
	public function testCanConstruct() {
20
21
		$this->assertInstanceOf(
22
			'\SES\HookRegistry',
23
			new HookRegistry()
24
		);
25
	}
26
27
	public function testRegister() {
28
29
		$parser = $this->getMockBuilder( '\Parser' )
30
			->disableOriginalConstructor()
31
			->getMock();
32
33
		$wgHooks = array();
34
35
		$instance = new HookRegistry();
36
		$instance->register( $wgHooks );
37
38
		$this->assertNotEmpty(
39
			$wgHooks
40
		);
41
42
		$this->assertHookIsExcutable(
43
			$wgHooks,
44
			'ParserFirstCallInit',
45
			array( &$parser )
46
		);
47
48
		$template = '';
49
50
		$this->assertHookIsExcutable(
51
			$wgHooks,
52
			'UserCreateForm',
53
			array( &$template )
54
		);
55
	}
56
57
	private function assertHookIsExcutable( $wgHooks, $hookName, $arguments ) {
58
		foreach ( $wgHooks[ $hookName ] as $hook ) {
59
			$this->assertInternalType(
60
				'boolean',
61
				call_user_func_array( $hook, $arguments )
62
			);
63
		}
64
	}
65
66
}
67