|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use SCI\ReferenceListOutputRenderer; |
|
6
|
|
|
use SMW\DIWikiPage; |
|
7
|
|
|
use SMW\Tests\PHPUnitCompat; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @covers \SCI\ReferenceListOutputRenderer |
|
11
|
|
|
* @group semantic-cite |
|
12
|
|
|
* |
|
13
|
|
|
* @license GNU GPL v2+ |
|
14
|
|
|
* @since 1.0 |
|
15
|
|
|
* |
|
16
|
|
|
* @author mwjames |
|
17
|
|
|
*/ |
|
18
|
|
|
class ReferenceListOutputRendererTest extends \PHPUnit_Framework_TestCase { |
|
19
|
|
|
|
|
20
|
|
|
use PHPUnitCompat; |
|
21
|
|
|
|
|
22
|
|
|
private $citationResourceMatchFinder; |
|
23
|
|
|
private $citationReferencePositionJournal; |
|
24
|
|
|
private $htmlColumnListRenderer; |
|
25
|
|
|
|
|
26
|
|
|
protected function setUp() : void { |
|
27
|
|
|
|
|
28
|
|
|
$this->citationResourceMatchFinder = $this->getMockBuilder( '\SCI\CitationResourceMatchFinder' ) |
|
29
|
|
|
->disableOriginalConstructor() |
|
30
|
|
|
->getMock(); |
|
31
|
|
|
|
|
32
|
|
|
$this->citationReferencePositionJournal = $this->getMockBuilder( '\SCI\CitationReferencePositionJournal' ) |
|
33
|
|
|
->disableOriginalConstructor() |
|
34
|
|
|
->getMock(); |
|
35
|
|
|
|
|
36
|
|
|
$this->htmlColumnListRenderer = $this->getMockBuilder( '\SMW\MediaWiki\Renderer\HtmlColumnListRenderer' ) |
|
37
|
|
|
->disableOriginalConstructor() |
|
38
|
|
|
->getMock(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testCanConstruct() { |
|
42
|
|
|
|
|
43
|
|
|
$this->assertInstanceOf( |
|
44
|
|
|
'\SCI\ReferenceListOutputRenderer', |
|
45
|
|
|
new ReferenceListOutputRenderer( |
|
46
|
|
|
$this->citationResourceMatchFinder, |
|
47
|
|
|
$this->citationReferencePositionJournal, |
|
48
|
|
|
$this->htmlColumnListRenderer |
|
49
|
|
|
) |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testSetterGetterForExternalUse() { |
|
54
|
|
|
|
|
55
|
|
|
$instance = new ReferenceListOutputRenderer( |
|
56
|
|
|
$this->citationResourceMatchFinder, |
|
57
|
|
|
$this->citationReferencePositionJournal, |
|
58
|
|
|
$this->htmlColumnListRenderer |
|
59
|
|
|
); |
|
60
|
|
|
|
|
61
|
|
|
$instance->setNumberOfReferenceListColumns( 4 ); |
|
62
|
|
|
|
|
63
|
|
|
$this->assertEquals( |
|
64
|
|
|
4, |
|
65
|
|
|
$instance->getNumberOfReferenceListColumns() |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
$instance->setReferenceListType( 'ol' ); |
|
69
|
|
|
|
|
70
|
|
|
$this->assertEquals( |
|
71
|
|
|
'ol', |
|
72
|
|
|
$instance->getReferenceListType() |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
$instance->setBrowseLinkToCitationResourceVisibility( true ); |
|
76
|
|
|
|
|
77
|
|
|
$this->assertEquals( |
|
78
|
|
|
true, |
|
79
|
|
|
$instance->getBrowseLinkToCitationResourceVisibility() |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function testRenderReferenceListForIncompleteJournal() { |
|
84
|
|
|
|
|
85
|
|
|
$this->citationReferencePositionJournal->expects( $this->once() ) |
|
86
|
|
|
->method( 'getJournalBySubject' ) |
|
87
|
|
|
->will( $this->returnValue( [ |
|
88
|
|
|
'reference-pos' => [ 'abc' => [] ], |
|
89
|
|
|
'reference-list' => [ 'abc' => 123 ] ] ) ); |
|
90
|
|
|
|
|
91
|
|
|
$this->citationResourceMatchFinder->expects( $this->once() ) |
|
92
|
|
|
->method( 'findCitationTextFor' ) |
|
93
|
|
|
->will( $this->returnValue( [ [], '' ] ) ); |
|
94
|
|
|
|
|
95
|
|
|
$instance = new ReferenceListOutputRenderer( |
|
96
|
|
|
$this->citationResourceMatchFinder, |
|
97
|
|
|
$this->citationReferencePositionJournal, |
|
98
|
|
|
$this->htmlColumnListRenderer |
|
99
|
|
|
); |
|
100
|
|
|
|
|
101
|
|
|
$instance->setNumberOfReferenceListColumns( 0 ); |
|
102
|
|
|
$instance->setResponsiveMonoColumnCharacterBoundLength( 100 ); |
|
103
|
|
|
$instance->setBrowseLinkToCitationResourceVisibility( true ); |
|
104
|
|
|
|
|
105
|
|
|
$this->assertInternalType( |
|
106
|
|
|
'string', |
|
107
|
|
|
$instance->doRenderReferenceListFor( DIWikiPage::newFromText( 'Foo' ) ) |
|
108
|
|
|
); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|