EntityRedirectLookupExceptionTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithOnlyRequiredArguments() 0 9 1
A testConstructorWithAllArguments() 0 10 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\EntityRedirectLookupException;
9
10
/**
11
 * @covers \Wikibase\DataModel\Services\Lookup\EntityRedirectLookupException
12
 *
13
 * @license GPL-2.0-or-later
14
 * @author Thiemo Kreuz
15
 */
16
class EntityRedirectLookupExceptionTest extends TestCase {
17
18
	public function testConstructorWithOnlyRequiredArguments() {
19
		$entityId = new ItemId( 'Q1' );
20
		$exception = new EntityRedirectLookupException( $entityId );
21
22
		$this->assertSame( $entityId, $exception->getEntityId() );
23
		$this->assertSame( 'Entity redirect lookup failed for: Q1', $exception->getMessage() );
24
		$this->assertSame( 0, $exception->getCode() );
25
		$this->assertNull( $exception->getPrevious() );
26
	}
27
28
	public function testConstructorWithAllArguments() {
29
		$entityId = new ItemId( 'Q1' );
30
		$previous = new Exception( 'previous' );
31
		$exception = new EntityRedirectLookupException( $entityId, 'customMessage', $previous );
32
33
		$this->assertSame( $entityId, $exception->getEntityId() );
34
		$this->assertSame( 'customMessage', $exception->getMessage() );
35
		$this->assertSame( 0, $exception->getCode() );
36
		$this->assertSame( $previous, $exception->getPrevious() );
37
	}
38
39
}
40