Completed
Push — master ( 379b27...5b49bb )
by
unknown
12s
created

testConstructorWithAllArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 0
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\Entity\PropertyId;
9
use Wikibase\DataModel\Services\Lookup\MaxReferenceDepthExhaustedException;
10
11
/**
12
 * @covers Wikibase\DataModel\Services\Lookup\MaxReferenceDepthExhaustedException
13
 *
14
 * @license GPL-2.0-or-later
15
 * @author Marius Hoch
16
 */
17
class MaxReferenceDepthExhaustedExceptionTest extends PHPUnit_Framework_TestCase {
18
19
	public function testConstructorWithOnlyRequiredArguments() {
20
		$entityId = new ItemId( 'Q1' );
21
		$propertyId = new PropertyId( 'P12' );
22
		$toIds = [
23
			new ItemId( 'Q5' ),
24
			new ItemId( 'Q2013' )
25
		];
26
		$exception = new MaxReferenceDepthExhaustedException( $entityId, $propertyId, $toIds, 44 );
27
28
		$this->assertSame( 44, $exception->getMaxDepth() );
29
		$this->assertSame(
30
			'Referenced entity id lookup failed: Maximum depth of 44 exhausted.',
31
			$exception->getMessage()
32
		);
33
		$this->assertSame( 0, $exception->getCode() );
34
		$this->assertNull( $exception->getPrevious() );
35
	}
36
37
	public function testConstructorWithAllArguments() {
38
		$entityId = new ItemId( 'Q1' );
39
		$propertyId = new PropertyId( 'P12' );
40
		$toIds = [
41
			new ItemId( 'Q5' ),
42
			new ItemId( 'Q2013' )
43
		];
44
		$previous = new Exception( 'previous' );
45
46
		$exception = new MaxReferenceDepthExhaustedException(
47
			$entityId,
48
			$propertyId,
49
			$toIds,
50
			123,
51
			'blah blah',
52
			$previous
53
		);
54
55
		$this->assertSame( 123, $exception->getMaxDepth() );
56
		$this->assertSame( 'blah blah', $exception->getMessage() );
57
		$this->assertSame( 0, $exception->getCode() );
58
		$this->assertSame( $previous, $exception->getPrevious() );
59
	}
60
61
}
62