Passed
Pull Request — master (#136)
by None
04:14
created

CitationResourceMatchFinderTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 75
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SCI\Tests;
4
5
use SCI\CitationResourceMatchFinder;
6
7
/**
8
 * @covers \SCI\CitationResourceMatchFinder
9
 * @group semantic-cite
10
 *
11
 * @license GNU GPL v2+
12
 * @since   1.0
13
 *
14
 * @author mwjames
15
 */
16
class CitationResourceMatchFinderTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$store = $this->getMockBuilder( '\SMW\Store' )
21
			->disableOriginalConstructor()
22
			->getMockForAbstractClass();
23
24
		$this->assertInstanceOf(
25
			'\SCI\CitationResourceMatchFinder',
26
			new CitationResourceMatchFinder( $store )
27
		);
28
	}
29
30
	/**
31
	 * @dataProvider uidTypeProvider
32
	 */
33
	public function testFindMatchForUidTypeOf( $key, $id ) {
34
35
		$queryResult = $this->getMockBuilder( '\SMWQueryResult' )
36
			->disableOriginalConstructor()
37
			->getMock();
38
39
		$store = $this->getMockBuilder( '\SMW\Store' )
40
			->disableOriginalConstructor()
41
			->getMockForAbstractClass();
42
43
		$store->expects( $this->once() )
44
			->method( 'getQueryResult' )
45
			->will( $this->returnValue( $queryResult ) );
46
47
		$instance = new CitationResourceMatchFinder( $store );
48
49
		$instance->findMatchForResourceIdentifierTypeToValue(
50
			$key,
51
			$id
52
		);
53
	}
54
55
	public function uidTypeProvider() {
56
57
		$provider[] = [
58
			'oclc',
59
			42
60
		];
61
62
		$provider[] = [
63
			'viaf',
64
			42
65
		];
66
67
		$provider[] = [
68
			'doi',
69
			42
70
		];
71
72
		$provider[] = [
73
			'pmid',
74
			42
75
		];
76
77
		$provider[] = [
78
			'pmcid',
79
			42
80
		];
81
82
		$provider[] = [
83
			'olid',
84
			42
85
		];
86
87
		return $provider;
88
	}
89
90
}
91