|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI\Tests\Bibtex; |
|
4
|
|
|
|
|
5
|
|
|
use SCI\Bibtex\BibtexParser; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @covers \SCI\Bibtex\BibtexParser |
|
9
|
|
|
* @group semantic-cite |
|
10
|
|
|
* |
|
11
|
|
|
* @license GNU GPL v2+ |
|
12
|
|
|
* @since 1.0 |
|
13
|
|
|
* |
|
14
|
|
|
* @author mwjames |
|
15
|
|
|
*/ |
|
16
|
|
|
class BibtexParserTest extends \PHPUnit_Framework_TestCase { |
|
17
|
|
|
|
|
18
|
|
|
public function testCanConstruct() { |
|
19
|
|
|
|
|
20
|
|
|
$this->assertInstanceOf( |
|
21
|
|
|
'\SCI\Bibtex\BibtexParser', |
|
22
|
|
|
new BibtexParser() |
|
23
|
|
|
); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @dataProvider bibtextProvider |
|
28
|
|
|
*/ |
|
29
|
|
|
public function testParse( $bibtex, $expected ) { |
|
30
|
|
|
|
|
31
|
|
|
$instance = new BibtexParser(); |
|
32
|
|
|
|
|
33
|
|
|
$this->assertEquals( |
|
34
|
|
|
$expected, |
|
35
|
|
|
$instance->parse( $bibtex ) |
|
36
|
|
|
); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function bibtextProvider() { |
|
40
|
|
|
|
|
41
|
|
|
$provider[] = [ |
|
42
|
|
|
"@article{einstein1935can, |
|
43
|
|
|
title={Can quantum-mechanical description of physical reality be considered complete?}, |
|
44
|
|
|
author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan}, |
|
45
|
|
|
journal={Physical review}, |
|
46
|
|
|
volume={47}, |
|
47
|
|
|
number={10}, |
|
48
|
|
|
pages={777}, |
|
49
|
|
|
year={1935}, |
|
50
|
|
|
publisher={APS} |
|
51
|
|
|
}", |
|
52
|
|
|
[ |
|
53
|
|
|
'type' => 'article', |
|
54
|
|
|
'reference' => 'einstein1935can', |
|
55
|
|
|
'title' => 'Can quantum-mechanical description of physical reality be considered complete?', |
|
56
|
|
|
'author' => 'Einstein, Albert and Podolsky, Boris and Rosen, Nathan', |
|
57
|
|
|
'journal' => 'Physical review', |
|
58
|
|
|
'volume' => '47', |
|
59
|
|
|
'number' => '10', |
|
60
|
|
|
'pages' => '777', |
|
61
|
|
|
'year' => '1935', |
|
62
|
|
|
'publisher' => 'APS' |
|
63
|
|
|
] |
|
64
|
|
|
]; |
|
65
|
|
|
|
|
66
|
|
|
$provider[] = [ |
|
67
|
|
|
"@book{marx2004capital, |
|
68
|
|
|
title={Capital (Volume 1: A Critique of Political Economy): A Critique of Political Economy}, |
|
69
|
|
|
author={Marx, Karl}, |
|
70
|
|
|
year={2004}, |
|
71
|
|
|
publisher={Digireads. com Publishing} |
|
72
|
|
|
}", |
|
73
|
|
|
[ |
|
74
|
|
|
'type' => 'book', |
|
75
|
|
|
'reference' => 'marx2004capital', |
|
76
|
|
|
'title' => 'Capital (Volume 1: A Critique of Political Economy): A Critique of Political Economy', |
|
77
|
|
|
'author' => 'Marx, Karl', |
|
78
|
|
|
'year' => '2004', |
|
79
|
|
|
'publisher' => 'Digireads. com Publishing' |
|
80
|
|
|
] |
|
81
|
|
|
]; |
|
82
|
|
|
|
|
83
|
|
|
#2 No reference |
|
84
|
|
|
$provider[] = [ |
|
85
|
|
|
"@article{, |
|
86
|
|
|
title={Vascular endothelial growth factor is a secreted angiogenic mitogen}, |
|
87
|
|
|
author={Leung, David W and Cachianes, George and Kuang, Wun-Jing and Goeddel, David V and Ferrara, Napoleone}, |
|
88
|
|
|
journal={Science}, |
|
89
|
|
|
volume={246}, |
|
90
|
|
|
number={4935}, |
|
91
|
|
|
pages={1306--1309}, |
|
92
|
|
|
year={1989}, |
|
93
|
|
|
publisher={American Association for the Advancement of Science} |
|
94
|
|
|
}", |
|
95
|
|
|
[ |
|
96
|
|
|
'type' => 'article', |
|
97
|
|
|
'reference' => '', |
|
98
|
|
|
'title' => 'Vascular endothelial growth factor is a secreted angiogenic mitogen', |
|
99
|
|
|
'author' => 'Leung, David W and Cachianes, George and Kuang, Wun-Jing and Goeddel, David V and Ferrara, Napoleone', |
|
100
|
|
|
'journal' => 'Science', |
|
101
|
|
|
'volume' => '246', |
|
102
|
|
|
'number' => '4935', |
|
103
|
|
|
'pages' => '1306--1309', |
|
104
|
|
|
'year' => '1989', |
|
105
|
|
|
'publisher' => 'American Association for the Advancement of Science' |
|
106
|
|
|
] |
|
107
|
|
|
]; |
|
108
|
|
|
|
|
109
|
|
|
#3 No reference |
|
110
|
|
|
$provider[] = [ |
|
111
|
|
|
"@inproceedings{clean, |
|
112
|
|
|
author = {First Author and Author, Second}, |
|
113
|
|
|
title = {Pr{\"a}diktive Teilbandcodierung mit Vektorquantisierung f{\"u}r hochqualitative Audiosignale}, |
|
114
|
|
|
booktitle = {8. ITG-Fachtagung H{\"o}rrundfunk}, |
|
115
|
|
|
year = {1988}, |
|
116
|
|
|
month = nov, |
|
117
|
|
|
pages = {252--256}, |
|
118
|
|
|
abstract = {Some Abstract, across |
|
119
|
|
|
two lines}, |
|
120
|
|
|
}", |
|
121
|
|
|
[ |
|
122
|
|
|
'type' => 'inproceedings', |
|
123
|
|
|
'reference' => 'clean', |
|
124
|
|
|
'author' => 'First Author and Author, Second', |
|
125
|
|
|
'title' => 'Pr{"a}diktive Teilbandcodierung mit Vektorquantisierung f{"u}r hochqualitative Audiosignale', |
|
126
|
|
|
'booktitle' => '8. ITG-Fachtagung H{"o}rrundfunk', |
|
127
|
|
|
'year' => '1988', |
|
128
|
|
|
'month' => 'nov', |
|
129
|
|
|
'pages' => '252--256', |
|
130
|
|
|
'abstract' => "Some Abstract, across |
|
131
|
|
|
two lines" |
|
132
|
|
|
] |
|
133
|
|
|
]; |
|
134
|
|
|
|
|
135
|
|
|
#4 invalid/unprocessable content format |
|
136
|
|
|
$provider[] = [ |
|
137
|
|
|
"foo", |
|
138
|
|
|
[] |
|
139
|
|
|
]; |
|
140
|
|
|
|
|
141
|
|
|
$provider[] = [ |
|
142
|
|
|
"@article{}", |
|
143
|
|
|
[] |
|
144
|
|
|
]; |
|
145
|
|
|
|
|
146
|
|
|
return $provider; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
} |
|
150
|
|
|
|