HookRegistryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 7 1
A testRegister() 0 7 1
A doTestRegisteredScribuntoExternalLibraries() 0 21 1
A assertThatHookIsExcutable() 0 6 1
1
<?php
2
3
namespace SMW\Scribunto\Tests;
4
5
use SMW\Scribunto\HookRegistry;
6
7
/**
8
 * @covers \SMW\Scribunto\HookRegistry
9
 * @group semantic-scribunto
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class HookRegistryTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\SMW\Scribunto\HookRegistry',
22
			new HookRegistry()
23
		);
24
	}
25
26
	public function testRegister() {
27
28
		$instance = new HookRegistry();
29
		$instance->register();
30
31
		$this->doTestRegisteredScribuntoExternalLibraries( $instance );
32
	}
33
34
	public function doTestRegisteredScribuntoExternalLibraries( $instance ) {
35
36
		$handler = 'ScribuntoExternalLibraries';
37
38
		$engine = '';
39
		$extraLibraries = [];
40
41
		$this->assertTrue(
42
			$instance->isRegistered( $handler )
43
		);
44
45
		$this->assertThatHookIsExcutable(
46
			$instance->getHandlerFor( $handler ),
47
			[ $engine, &$extraLibraries ]
48
		);
49
50
		$this->assertArrayHasKey(
51
			'mw.smw',
52
			$extraLibraries
53
		);
54
	}
55
56
	private function assertThatHookIsExcutable( \Closure $handler, $arguments ) {
57
		$this->assertInternalType(
58
			'boolean',
59
			call_user_func_array( $handler, $arguments )
60
		);
61
	}
62
63
}
64