HookRegistryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 11 1
A testRegister() 0 14 1
A doTestRegisteredInterwikiLoadPrefixHandler() 0 16 1
A assertThatHookIsExcutable() 0 6 1
1
<?php
2
3
namespace SEQL\Tests;
4
5
use SEQL\HookRegistry;
6
7
/**
8
 * @covers \SEQL\HookRegistry
9
 * @group semantic-external-query-lookup
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
		$options = array(
21
			'externalRepositoryEndpoints' => array(),
22
		);
23
24
		$this->assertInstanceOf(
25
			'\SEQL\HookRegistry',
26
			new HookRegistry( $options )
27
		);
28
	}
29
30
	public function testRegister() {
31
32
		$options = array(
33
			'externalRepositoryEndpoints' => array(),
34
		);
35
36
		$instance = new HookRegistry(
37
			$options
38
		);
39
40
		$instance->register();
41
42
		$this->doTestRegisteredInterwikiLoadPrefixHandler( $instance );
43
	}
44
45
	public function doTestRegisteredInterwikiLoadPrefixHandler( $instance ) {
46
47
		$handler = 'InterwikiLoadPrefix';
48
49
		$prefix = '';
50
		$interwiki = array();
51
52
		$this->assertTrue(
53
			$instance->isRegistered( $handler )
54
		);
55
56
		$this->assertThatHookIsExcutable(
57
			$instance->getHandlerFor( $handler ),
58
			array( $prefix, &$interwiki )
59
		);
60
	}
61
62
	private function assertThatHookIsExcutable( \Closure $handler, $arguments ) {
63
		$this->assertInternalType(
64
			'boolean',
65
			call_user_func_array( $handler, $arguments )
66
		);
67
	}
68
69
}
70