Completed
Push — master ( 23c630...ec7273 )
by
unknown
02:52
created

TermLookupExceptionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithOnlyRequiredArguments() 0 12 1
A testConstructorWithAllArguments() 0 15 1
1
<?php
2
3
namespace Wikibase\DataModel\Services\Tests\Lookup;
4
5
use Exception;
6
use PHPUnit_Framework_TestCase;
7
use Wikibase\DataModel\Entity\ItemId;
8
use Wikibase\DataModel\Services\Lookup\TermLookupException;
9
10
/**
11
 * @covers Wikibase\DataModel\Services\Lookup\TermLookupException
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Thiemo Mättig
15
 */
16
class TermLookupExceptionTest extends PHPUnit_Framework_TestCase {
17
18
	public function testConstructorWithOnlyRequiredArguments() {
19
		$entityId = new ItemId( 'Q1' );
20
		$exception = new TermLookupException( $entityId, array( 'de', 'en' ) );
21
22
		$this->assertSame( $entityId, $exception->getEntityId() );
23
		$this->assertSame(
24
			'Term lookup failed for: Q1 with language codes: de, en',
25
			$exception->getMessage()
26
		);
27
		$this->assertSame( 0, $exception->getCode() );
28
		$this->assertNull( $exception->getPrevious() );
29
	}
30
31
	public function testConstructorWithAllArguments() {
32
		$entityId = new ItemId( 'Q1' );
33
		$previous = new Exception( 'previous' );
34
		$exception = new TermLookupException(
35
			$entityId,
36
			array( 'de', 'en' ),
37
			'customMessage',
38
			$previous
39
		);
40
41
		$this->assertSame( $entityId, $exception->getEntityId() );
42
		$this->assertSame( 'customMessage', $exception->getMessage() );
43
		$this->assertSame( 0, $exception->getCode() );
44
		$this->assertSame( $previous, $exception->getPrevious() );
45
	}
46
47
}
48