|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI\Tests\Specials\CitableMetadata; |
|
4
|
|
|
|
|
5
|
|
|
use SCI\Specials\CitableMetadata\HtmlResponseParserRenderer; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @covers \SCI\Specials\CitableMetadata\HtmlResponseParserRenderer |
|
9
|
|
|
* @group semantic-cite |
|
10
|
|
|
* |
|
11
|
|
|
* @license GNU GPL v2+ |
|
12
|
|
|
* @since 1.0 |
|
13
|
|
|
* |
|
14
|
|
|
* @author mwjames |
|
15
|
|
|
*/ |
|
16
|
|
|
class HtmlResponseParserRendererTest extends \PHPUnit_Framework_TestCase { |
|
17
|
|
|
|
|
18
|
|
|
public function testCanConstruct() { |
|
19
|
|
|
|
|
20
|
|
|
$responseParser = $this->getMockBuilder( '\Onoi\Remi\ResponseParser' ) |
|
21
|
|
|
->disableOriginalConstructor() |
|
22
|
|
|
->getMockForAbstractClass(); |
|
23
|
|
|
|
|
24
|
|
|
$this->assertInstanceOf( |
|
25
|
|
|
'\SCI\Specials\CitableMetadata\HtmlResponseParserRenderer', |
|
26
|
|
|
new HtmlResponseParserRenderer( $responseParser ) |
|
27
|
|
|
); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testGetRawResponse() { |
|
31
|
|
|
|
|
32
|
|
|
$responseParser = $this->getMockBuilder( '\Onoi\Remi\ResponseParser' ) |
|
33
|
|
|
->disableOriginalConstructor() |
|
34
|
|
|
->getMockForAbstractClass(); |
|
35
|
|
|
|
|
36
|
|
|
$responseParser->expects( $this->once() ) |
|
37
|
|
|
->method( 'getRawResponse' ) |
|
38
|
|
|
->with( $this->identicalTo( 42 ) ); |
|
39
|
|
|
|
|
40
|
|
|
$instance = new HtmlResponseParserRenderer( |
|
41
|
|
|
$responseParser |
|
42
|
|
|
); |
|
43
|
|
|
|
|
44
|
|
|
$instance->getRawResponse( 42 ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testRenderText() { |
|
48
|
|
|
|
|
49
|
|
|
$bibliographicFilteredRecord = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) |
|
50
|
|
|
->disableOriginalConstructor() |
|
51
|
|
|
->getMock(); |
|
52
|
|
|
|
|
53
|
|
|
$responseParser = $this->getMockBuilder( '\Onoi\Remi\ResponseParser' ) |
|
54
|
|
|
->disableOriginalConstructor() |
|
55
|
|
|
->getMockForAbstractClass(); |
|
56
|
|
|
|
|
57
|
|
|
$responseParser->expects( $this->once() ) |
|
58
|
|
|
->method( 'doFilterResponseFor' ) |
|
59
|
|
|
->with( $this->identicalTo( 42 ) ); |
|
60
|
|
|
|
|
61
|
|
|
$responseParser->expects( $this->atLeastOnce() ) |
|
62
|
|
|
->method( 'getMessages' ) |
|
63
|
|
|
->will( $this->returnValue( [] ) ); |
|
64
|
|
|
|
|
65
|
|
|
$responseParser->expects( $this->atLeastOnce() ) |
|
66
|
|
|
->method( 'getFilteredRecord' ) |
|
67
|
|
|
->will( $this->returnValue( $bibliographicFilteredRecord ) ); |
|
68
|
|
|
|
|
69
|
|
|
$instance = new HtmlResponseParserRenderer( |
|
70
|
|
|
$responseParser |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
$instance->renderTextFor( 42 ); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|