HookRegistryTest::assertThatHookIsExcutable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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