1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Onoi\Remi\Tests\Integration\CrossRef; |
4
|
|
|
|
5
|
|
|
use Onoi\Remi\FilteredHttpResponseParserFactory; |
6
|
|
|
use Onoi\Remi\FilteredRecord; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @group semantic-cite |
10
|
|
|
* |
11
|
|
|
* @license GNU GPL v2+ |
12
|
|
|
* @since 0.1 |
13
|
|
|
* |
14
|
|
|
* @author mwjames |
15
|
|
|
*/ |
16
|
|
|
class CrossRefCannedResponseParserTest extends \PHPUnit_Framework_TestCase { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @dataProvider fileProvider |
20
|
|
|
*/ |
21
|
|
|
public function testParser( $id, $httpRequestFile, $expectedResultFile ) { |
22
|
|
|
|
23
|
|
|
$contents = file_get_contents( $httpRequestFile ); |
24
|
|
|
|
25
|
|
|
$httpRequest = $this->getMockBuilder( '\Onoi\HttpRequest\HttpRequest' ) |
26
|
|
|
->disableOriginalConstructor() |
27
|
|
|
->getMock(); |
28
|
|
|
|
29
|
|
|
$httpRequest->expects( $this->any() ) |
30
|
|
|
->method( 'execute' ) |
31
|
|
|
->will( $this->returnValue( $contents ) ); |
32
|
|
|
|
33
|
|
|
$httpRequest->expects( $this->any() ) |
34
|
|
|
->method( 'getLastError' ) |
35
|
|
|
->will( $this->returnValue( '' ) ); |
36
|
|
|
|
37
|
|
|
$filteredHttpResponseParserFactory = new FilteredHttpResponseParserFactory( |
38
|
|
|
$httpRequest |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
$instance = $filteredHttpResponseParserFactory->newCrossRefFilteredHttpResponseParser( |
42
|
|
|
new FilteredRecord() |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$this->assertEquals( |
46
|
|
|
$contents, |
47
|
|
|
$instance->getRawResponseById( $id ) |
|
|
|
|
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
$instance->doFilterResponseById( $id ); |
51
|
|
|
|
52
|
|
|
$this->assertJsonStringEqualsJsonFile( |
53
|
|
|
$expectedResultFile, |
54
|
|
|
$instance->getFilteredRecord()->asJsonString() |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function fileProvider() { |
59
|
|
|
|
60
|
|
|
$path = __DIR__ . '/Fixtures/'; |
61
|
|
|
$provider = array(); |
62
|
|
|
|
63
|
|
|
$provider[] = array( |
64
|
|
|
'10.1007/978-0-387-76978-3', |
65
|
|
|
$path . '10.1007-2F978-0-387-76978-3.json', |
66
|
|
|
$path . '10.1007-2F978-0-387-76978-3.expected' |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
$provider[] = array( |
70
|
|
|
'10.5555/12345678', |
71
|
|
|
$path . '10.5555-2F12345678.json', |
72
|
|
|
$path . '10.5555-2F12345678.expected' |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
$provider[] = array( |
77
|
|
|
'10.1126/science.1152662', |
78
|
|
|
$path . '10.1126-2Fscience.1152662.json', |
79
|
|
|
$path . '10.1126-2Fscience.1152662.expected' |
80
|
|
|
); |
81
|
|
|
|
82
|
|
|
// Dataset |
83
|
|
|
$provider[] = array( |
84
|
|
|
'10.5524/100005', |
85
|
|
|
$path . '10.5524-2F100005.json', |
86
|
|
|
$path . '10.5524-2F100005.expected' |
87
|
|
|
); |
88
|
|
|
|
89
|
|
|
return $provider; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
} |
93
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.