EntityIdForTermCacheTest::testContainsTrue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\EntityStore\Cache;
4
5
use Doctrine\Common\Cache\ArrayCache;
6
use Wikibase\DataModel\Entity\ItemId;
7
use Wikibase\DataModel\Term\Term;
8
9
/**
10
 * @covers Wikibase\EntityStore\Cache\EntityIdForTermCache
11
 *
12
 * @licence GPLv2+
13
 * @author Thomas Pellissier Tanon
14
 */
15
class EntityIdForTermCacheTest extends \PHPUnit_Framework_TestCase {
16
17
	public function testFetch() {
18
		$cache = new EntityIdForTermCache( new ArrayCache() );
19
		$cache->save( new Term( 'en', 'foo' ), 'item', [ new ItemId( 'Q42' ) ] );
20
21
		$this->assertEquals( [ new ItemId( 'Q42' ) ], $cache->fetch( new Term( 'en', 'foo' ), 'item' ) );
22
	}
23
24
	public function testFetchWithException() {
25
		$this->setExpectedException( '\OutOfBoundsException' );
26
27
		$cache = new EntityIdForTermCache( new ArrayCache() );
28
		$cache->fetch( new Term( 'en', 'foo' ), 'item' );
29
	}
30
31
	public function testContainsTrue() {
32
		$cache = new EntityIdForTermCache( new ArrayCache() );
33
		$cache->save( new Term( 'en', 'foo' ), 'item', [ new ItemId( 'Q42' ) ] );
34
35
		$this->assertTrue( $cache->contains( new Term( 'en', 'foo' ), 'item' ) );
36
	}
37
38
	public function testContainsFalse() {
39
		$cache = new EntityIdForTermCache( new ArrayCache() );
40
41
		$this->assertFalse( $cache->contains( new Term( 'en', 'foo' ), 'item' ) );
42
	}
43
}
44