|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Onoi\Remi\Tests\Integration\Oclc; |
|
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 OclcCannedResponseParserTest 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->newOclcFilteredHttpResponseParser( |
|
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
|
|
|
'2776723', |
|
65
|
|
|
$path . '2776723.json', |
|
66
|
|
|
$path . '2776723.expected' |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$provider[] = array( |
|
70
|
|
|
'24880509', |
|
71
|
|
|
$path . '24880509.json', |
|
72
|
|
|
$path . '24880509.expected' |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
$provider[] = array( |
|
76
|
|
|
'31754096', |
|
77
|
|
|
$path . '31754096.json', |
|
78
|
|
|
$path . '31754096.expected' |
|
79
|
|
|
); |
|
80
|
|
|
|
|
81
|
|
|
$provider[] = array( |
|
82
|
|
|
'41266045', |
|
83
|
|
|
$path . '41266045.json', |
|
84
|
|
|
$path . '41266045.expected' |
|
85
|
|
|
); |
|
86
|
|
|
|
|
87
|
|
|
$provider[] = array( |
|
88
|
|
|
'74330434', |
|
89
|
|
|
$path . '74330434.json', |
|
90
|
|
|
$path . '74330434.expected' |
|
91
|
|
|
); |
|
92
|
|
|
|
|
93
|
|
|
return $provider; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
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.