1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Onoi\Remi\Tests\Integration\Viaf; |
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 ViafCannedResponseParserTest 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->newViafFilteredHttpResponseParser( |
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
|
|
|
'253484422', |
65
|
|
|
$path . '253484422.xml', |
66
|
|
|
$path . '253484422.expected' |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
$provider[] = array( |
70
|
|
|
'50566653', |
71
|
|
|
$path . '50566653.xml', |
72
|
|
|
$path . '50566653.expected' |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
$provider[] = array( |
76
|
|
|
'99929837', |
77
|
|
|
$path . '99929837.xml', |
78
|
|
|
$path . '99929837.expected' |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
// Corporate |
82
|
|
|
$provider[] = array( |
83
|
|
|
'138978451', |
84
|
|
|
$path . '138978451.xml', |
85
|
|
|
$path . '138978451.expected' |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
return $provider; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
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.