|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use SCI\CitationReferencePositionJournal; |
|
6
|
|
|
use SMW\Tests\PHPUnitCompat; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @covers \SCI\CitationReferencePositionJournal |
|
10
|
|
|
* @group semantic-cite |
|
11
|
|
|
* |
|
12
|
|
|
* @license GNU GPL v2+ |
|
13
|
|
|
* @since 1.0 |
|
14
|
|
|
* |
|
15
|
|
|
* @author mwjames |
|
16
|
|
|
*/ |
|
17
|
|
|
class CitationReferencePositionJournalTest extends \PHPUnit_Framework_TestCase { |
|
18
|
|
|
|
|
19
|
|
|
use PHPUnitCompat; |
|
20
|
|
|
|
|
21
|
|
|
private $cache; |
|
22
|
|
|
private $cacheKeyProvider; |
|
23
|
|
|
|
|
24
|
|
|
protected function setUp() : void { |
|
25
|
|
|
|
|
26
|
|
|
$this->cache = $this->getMockBuilder( '\Onoi\Cache\Cache' ) |
|
27
|
|
|
->disableOriginalConstructor() |
|
28
|
|
|
->getMock(); |
|
29
|
|
|
|
|
30
|
|
|
$this->cacheKeyProvider = $this->getMockBuilder( '\SCI\CacheKeyProvider' ) |
|
31
|
|
|
->disableOriginalConstructor() |
|
32
|
|
|
->getMock(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testCanConstruct() { |
|
36
|
|
|
|
|
37
|
|
|
$this->assertInstanceOf( |
|
38
|
|
|
'\SCI\CitationReferencePositionJournal', |
|
39
|
|
|
new CitationReferencePositionJournal( $this->cache, $this->cacheKeyProvider ) |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testUnboundReferenceList() { |
|
44
|
|
|
|
|
45
|
|
|
$instance = new CitationReferencePositionJournal( |
|
46
|
|
|
$this->cache, |
|
47
|
|
|
$this->cacheKeyProvider |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertNull( |
|
51
|
|
|
$instance->buildJournalForUnboundReferenceList( [] ) |
|
52
|
|
|
); |
|
53
|
|
|
|
|
54
|
|
|
$this->assertInternalType( |
|
55
|
|
|
'array', |
|
56
|
|
|
$instance->buildJournalForUnboundReferenceList( [ 'foo' ] ) |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testTryToAddJournalEntryForNullSubject() { |
|
61
|
|
|
|
|
62
|
|
|
$instance = new CitationReferencePositionJournal( |
|
63
|
|
|
$this->cache, |
|
64
|
|
|
$this->cacheKeyProvider |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
$this->assertNull( |
|
68
|
|
|
$instance->addJournalEntryFor( null, 'foo' ) |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function testTryToGetJournalBySubject() { |
|
73
|
|
|
|
|
74
|
|
|
$subject = \SMW\DIWikiPage::newFromText( __METHOD__ ); |
|
75
|
|
|
|
|
76
|
|
|
$this->cacheKeyProvider->expects( $this->once() ) |
|
77
|
|
|
->method( 'getCacheKeyForCitationReference' ) |
|
78
|
|
|
->with( $this->equalTo( $subject->getHash() ) ); |
|
79
|
|
|
|
|
80
|
|
|
$instance = new CitationReferencePositionJournal( |
|
81
|
|
|
$this->cache, |
|
82
|
|
|
$this->cacheKeyProvider |
|
83
|
|
|
); |
|
84
|
|
|
|
|
85
|
|
|
$instance->getJournalBySubject( $subject ); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|