InMemoryEntityLookupTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 0
cbo 3
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetEntityDocumentsForIds() 0 10 1
A testGetEntityDocumentForId() 0 7 1
A testGetEntityDocumentWithoutDocument() 0 5 1
1
<?php
2
3
namespace Wikibase\EntityStore\InMemory;
4
5
use Wikibase\DataModel\Entity\Item;
6
use Wikibase\DataModel\Entity\ItemId;
7
8
/**
9
 * @covers Wikibase\EntityStore\InMemory\InMemoryEntityLookup
10
 *
11
 * @licence GPLv2+
12
 * @author Thomas Pellissier Tanon
13
 */
14
class InMemoryEntityLookupTest extends \PHPUnit_Framework_TestCase {
15
16
	public function testGetEntityDocumentsForIds() {
17
		$item = new Item( new ItemId( 'Q42' ) );
18
19
		$lookup = new InMemoryEntityLookup( [ $item ] );
20
21
		$this->assertEquals(
22
			[ $item ],
23
			$lookup->getEntityDocumentsForIds( [ new ItemId( 'Q42' ), new ItemId( 'Q43' ) ] )
24
		);
25
	}
26
27
	public function testGetEntityDocumentForId() {
28
		$item = new Item( new ItemId( 'Q42' ) );
29
30
		$lookup = new InMemoryEntityLookup( [ $item ] );
31
32
		$this->assertEquals( $item, $lookup->getEntityDocumentForId( new ItemId( 'Q42' ) ) );
33
	}
34
35
	public function testGetEntityDocumentWithoutDocument() {
36
		$lookup = new InMemoryEntityLookup( [] );
37
38
		$this->assertNull( $lookup->getEntityDocumentForId( new ItemId( 'Q42' ) ) );
39
	}
40
}
41