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

BibtexAuthorListParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 181
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 181
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SCI\Tests\Bibtex;
4
5
use SCI\Bibtex\BibtexAuthorListParser;
6
7
/**
8
 * @covers \SCI\Bibtex\BibtexAuthorListParser
9
 * @group semantic-cite
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class BibtexAuthorListParserTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\SCI\Bibtex\BibtexAuthorListParser',
22
			new BibtexAuthorListParser()
23
		);
24
	}
25
26
	/**
27
	 * @dataProvider authorListProvider
28
	 */
29
	public function testParse( $authorList, $expected ) {
30
31
		$instance = new BibtexAuthorListParser();
32
33
		$this->assertEquals(
34
			$expected,
35
			$instance->parse( $authorList )
36
		);
37
	}
38
39
	public function authorListProvider() {
40
41
		$provider = [];
42
43
		// http://artis.imag.fr/~Xavier.Decoret/resources/xdkbibtex/bibtex_summary.html
44
		$provider[] = [
45
			 'AA BB',
46
			[
47
				'AA BB'
48
			]
49
		];
50
51
		$provider[] = [
52
			 'AA',
53
			[
54
				'AA'
55
			]
56
		];
57
58
		$provider[] = [
59
			 'AA bb',
60
			[
61
				'AA bb'
62
			]
63
		];
64
65
		$provider[] = [
66
			 'AA bb CC',
67
			[
68
				'AA bb CC'
69
			]
70
		];
71
72
		$provider[] = [
73
			 'AA bb CC dd EE',
74
			[
75
				'AA CC bb dd EE'
76
			]
77
		];
78
79
		$provider[] = [
80
			 'AA 1B cc dd',
81
			[
82
				'AA 1B cc dd'
83
			]
84
		];
85
86
		$provider[] = [
87
			 'AA {b}B cc dd',
88
			[
89
				'AA b'
90
			]
91
		];
92
93
		$provider[] = [
94
			 'AA \BB{b} cc dd',
95
			[
96
				'AA \BB b'
97
			]
98
		];
99
100
		$provider[] = [
101
			 'bb CC dd EE, AA',
102
			[
103
				'AA bb CC dd EE'
104
			]
105
		];
106
107
		$provider[] = [
108
			 'bb CC,XX, AA',
109
			[
110
				'AA bb CC XX'
111
			]
112
		];
113
114
		$provider[] = [
115
			 'Einstein, Albert and Podolsky, Boris and Rosen, Nathan',
116
			[
117
				'Albert Einstein',
118
				'Boris Podolsky',
119
				'Nathan Rosen'
120
			]
121
		];
122
123
		$provider[] = [
124
			 'Leung, David W and Cachianes, George and Kuang, Wun-Jing and Goeddel, David V and Ferrara, Napoleone',
125
			[
126
				'David W Leung',
127
				'George Cachianes',
128
				'Wun-Jing Kuang',
129
				'David V Goeddel',
130
				'Napoleone Ferrara'
131
			]
132
		];
133
134
		$provider[] = [
135
			 'S. Zhang and C. Zhu and J. K. O. Sin and P. K. T. Mok',
136
			[
137
				'S Zhang',
138
				'C Zhu',
139
				'J K O Sin',
140
				'P K T Mok'
141
			]
142
		];
143
144
		$provider[] = [
145
			 'R. M. A. Dawson and Z. Shen and D. A. Furst and
146
                   S. Connor and J. Hsu and M. G. Kane and R. G. Stewart and
147
                   A. Ipri and C. N. King and P. J. Green and R. T. Flegal
148
                   and S. Pearson and W. A. Barrow and E. Dickey and K. Ping
149
                   and C. W. Tang and S. Van. Slyke and
150
                   F. Chen and J. Shi and J. C. Sturm and M. H. Lu',
151
			[
152
				'R M A Dawson',
153
				'Z Shen',
154
				'D A Furst',
155
				'S Connor',
156
				'J Hsu',
157
				'M G Kane',
158
				'R G Stewart',
159
				'A Ipri',
160
				'C N King',
161
				'P J Green',
162
				'Flegal R T',
163
				'S Pearson',
164
				'W A Barrow',
165
				'E Dickey',
166
				'Ping K',
167
				'C W Tang',
168
				'Van. S Slyke',
169
				'F Chen',
170
				'J Shi',
171
				'J C Sturm',
172
				'M H Lu'
173
			]
174
		];
175
176
		// van
177
		$provider[] = [
178
			 'van den Bout, D. E.',
179
			[
180
				'D E van den Bout'
181
			]
182
		];
183
184
		// Jr.
185
		$provider[] = [
186
			 'Osgood, Jr., R. M.',
187
			[
188
				'R M Osgood Jr.'
189
			]
190
		];
191
192
193
		return $provider;
194
	}
195
196
}
197