1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Wikibase\EntityStore\Cache; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Cache\ArrayCache; |
6
|
|
|
use Wikibase\EntityStore\EntityStoreTest; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @covers Wikibase\EntityStore\Cache\CachedEntityStore |
10
|
|
|
* |
11
|
|
|
* @licence GPLv2+ |
12
|
|
|
* @author Thomas Pellissier Tanon |
13
|
|
|
*/ |
14
|
|
|
class CachedEntityStoreTest extends EntityStoreTest { |
15
|
|
|
|
16
|
|
|
public function testGetEntityDocumentLookup() { |
17
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
18
|
|
|
->disableOriginalConstructor() |
19
|
|
|
->getMock(); |
20
|
|
|
$storeMock->expects( $this->once() ) |
21
|
|
|
->method( 'getEntityDocumentLookup' ) |
22
|
|
|
->willReturn( $this->getMock( 'Wikibase\EntityStore\EntityDocumentLookup' ) ); |
23
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
24
|
|
|
|
25
|
|
|
$this->assertInstanceOf( 'Wikibase\EntityStore\EntityDocumentLookup', $store->getEntityDocumentLookup() ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testGetItemLookup() { |
29
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
30
|
|
|
->disableOriginalConstructor() |
31
|
|
|
->getMock(); |
32
|
|
|
$storeMock->expects( $this->once() ) |
33
|
|
|
->method( 'getItemLookup' ) |
34
|
|
|
->willReturn( $this->getMock( 'Wikibase\DataModel\Services\Lookup\ItemLookup' ) ); |
35
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
36
|
|
|
|
37
|
|
|
$this->assertInstanceOf( 'Wikibase\DataModel\Services\Lookup\ItemLookup', $store->getItemLookup() ); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testGetPropertyLookup() { |
41
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
42
|
|
|
->disableOriginalConstructor() |
43
|
|
|
->getMock(); |
44
|
|
|
$storeMock->expects( $this->once() ) |
45
|
|
|
->method( 'getPropertyLookup' ) |
46
|
|
|
->willReturn( $this->getMock( 'Wikibase\DataModel\Services\Lookup\PropertyLookup' ) ); |
47
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
48
|
|
|
|
49
|
|
|
$this->assertInstanceOf( 'Wikibase\DataModel\Services\Lookup\PropertyLookup', $store->getPropertyLookup() ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testGetEntityDocumentSaver() { |
53
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
54
|
|
|
->disableOriginalConstructor() |
55
|
|
|
->getMock(); |
56
|
|
|
$storeMock->expects( $this->once() ) |
57
|
|
|
->method( 'getEntityDocumentSaver' ) |
58
|
|
|
->willReturn( $this->getMock( 'Wikibase\EntityStore\EntityDocumentSaver' ) ); |
59
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
60
|
|
|
|
61
|
|
|
$this->assertInstanceOf( 'Wikibase\EntityStore\EntityDocumentSaver', $store->getEntityDocumentSaver() ); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testGetItemIdForTermLookup() { |
65
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
66
|
|
|
->disableOriginalConstructor() |
67
|
|
|
->getMock(); |
68
|
|
|
$storeMock->expects( $this->once() ) |
69
|
|
|
->method( 'getItemIdForTermLookup' ) |
70
|
|
|
->willReturn( $this->getMock( 'Wikibase\EntityStore\ItemIdForTermLookup' ) ); |
71
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
72
|
|
|
|
73
|
|
|
$this->assertInstanceOf( 'Wikibase\EntityStore\ItemIdForTermLookup', $store->getItemIdForTermLookup() ); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testGetPropertyIdForTermLookup() { |
77
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
78
|
|
|
->disableOriginalConstructor() |
79
|
|
|
->getMock(); |
80
|
|
|
$storeMock->expects( $this->once() ) |
81
|
|
|
->method( 'getPropertyIdForTermLookup' ) |
82
|
|
|
->willReturn( $this->getMock( 'Wikibase\EntityStore\PropertyIdForTermLookup' ) ); |
83
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
84
|
|
|
|
85
|
|
|
$this->assertInstanceOf( 'Wikibase\EntityStore\PropertyIdForTermLookup', $store->getPropertyIdForTermLookup() ); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function testGetItemIdForQueryLookup() { |
89
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
90
|
|
|
->disableOriginalConstructor() |
91
|
|
|
->getMock(); |
92
|
|
|
$storeMock->expects( $this->once() ) |
93
|
|
|
->method( 'getItemIdForQueryLookup' ) |
94
|
|
|
->willReturn( $this->getMock( 'Wikibase\EntityStore\ItemIdForQueryLookup' ) ); |
95
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
96
|
|
|
|
97
|
|
|
$this->assertInstanceOf( 'Wikibase\EntityStore\ItemIdForQueryLookup', $store->getItemIdForQueryLookup() ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function testGetPropertyIdForQueryLookup() { |
101
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
102
|
|
|
->disableOriginalConstructor() |
103
|
|
|
->getMock(); |
104
|
|
|
$storeMock->expects( $this->once() ) |
105
|
|
|
->method( 'getPropertyIdForQueryLookup' ) |
106
|
|
|
->willReturn( $this->getMock( 'Wikibase\EntityStore\PropertyIdForQueryLookup' ) ); |
107
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
108
|
|
|
|
109
|
|
|
$this->assertInstanceOf( 'Wikibase\EntityStore\PropertyIdForQueryLookup', $store->getPropertyIdForQueryLookup() ); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function testSetupStore() { |
113
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
114
|
|
|
->disableOriginalConstructor() |
115
|
|
|
->getMock(); |
116
|
|
|
$storeMock->expects( $this->once() ) |
117
|
|
|
->method( 'setupStore' ); |
118
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
119
|
|
|
|
120
|
|
|
$store->setupStore(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function testSetupIndexes() { |
124
|
|
|
$storeMock = $this->getMockBuilder( 'Wikibase\EntityStore\EntityStore' ) |
125
|
|
|
->disableOriginalConstructor() |
126
|
|
|
->getMock(); |
127
|
|
|
$storeMock->expects( $this->once() ) |
128
|
|
|
->method( 'setupIndexes' ); |
129
|
|
|
$store = new CachedEntityStore( $storeMock, new ArrayCache() ); |
130
|
|
|
|
131
|
|
|
$store->setupIndexes(); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|