HookRegistryTest::testCanConstruct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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