1 | <?php |
||
16 | class OLResponseParserTest extends \PHPUnit_Framework_TestCase { |
||
17 | |||
18 | public function testCanConstruct() { |
||
19 | |||
20 | $olFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\OpenLibrary\OLFilteredHttpResponseParser' ) |
||
21 | ->disableOriginalConstructor() |
||
22 | ->getMock(); |
||
23 | |||
24 | $this->assertInstanceOf( |
||
25 | '\Onoi\Remi\ResponseParser', |
||
26 | new OLResponseParser( $olFilteredHttpResponseParser ) |
||
27 | ); |
||
28 | } |
||
29 | |||
30 | public function testInterfaceMethods() { |
||
31 | |||
32 | $olFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\OpenLibrary\OLFilteredHttpResponseParser' ) |
||
33 | ->disableOriginalConstructor() |
||
34 | ->getMock(); |
||
35 | |||
36 | $instance = new OLResponseParser( $olFilteredHttpResponseParser ); |
||
37 | |||
38 | $this->assertNull( |
||
39 | $instance->usesCache() |
||
40 | ); |
||
41 | |||
42 | $this->assertNull( |
||
43 | $instance->getMessages() |
||
44 | ); |
||
45 | |||
46 | $this->assertNull( |
||
47 | $instance->getFilteredRecord() |
||
48 | ); |
||
49 | |||
50 | $this->assertNull( |
||
51 | $instance->getRawResponse( 42 ) |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @dataProvider idProvider |
||
57 | */ |
||
58 | public function testDoParseForId( $id, $expects ) { |
||
59 | |||
60 | $record = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) |
||
61 | ->disableOriginalConstructor() |
||
62 | ->getMock(); |
||
63 | |||
64 | $olFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\OpenLibrary\OLFilteredHttpResponseParser' ) |
||
65 | ->disableOriginalConstructor() |
||
66 | ->getMock(); |
||
67 | |||
68 | $olFilteredHttpResponseParser->expects( $this->any() ) |
||
69 | ->method( 'getFilteredRecord' ) |
||
70 | ->will( $this->returnValue( $record ) ); |
||
71 | |||
72 | $olFilteredHttpResponseParser->expects( $expects ) |
||
73 | ->method( 'doFilterResponseFor' ); |
||
74 | |||
75 | $instance = new OLResponseParser( $olFilteredHttpResponseParser ); |
||
76 | $instance->doFilterResponseFor( $id ); |
||
77 | } |
||
78 | |||
79 | public function idProvider() { |
||
80 | |||
81 | $provider[] = [ |
||
82 | 'abc', |
||
83 | $this->once() |
||
84 | ]; |
||
85 | |||
86 | $provider[] = [ |
||
87 | 'OL54846467', |
||
88 | $this->once() |
||
89 | ]; |
||
90 | |||
91 | return $provider; |
||
92 | } |
||
93 | |||
94 | } |
||
95 |