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\MaxReferencedEntityVisitsExhaustedException; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @covers Wikibase\DataModel\Services\Lookup\MaxReferencedEntityVisitsExhaustedException |
13
|
|
|
* |
14
|
|
|
* @license GPL-2.0-or-later |
15
|
|
|
* @author Marius Hoch |
16
|
|
|
*/ |
17
|
|
|
class MaxReferencedEntityVisitsExhaustedExceptionTest 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 MaxReferencedEntityVisitsExhaustedException( $entityId, $propertyId, $toIds, 44 ); |
27
|
|
|
|
28
|
|
|
$this->assertSame( 44, $exception->getMaxEntityVisits() ); |
29
|
|
|
$this->assertSame( |
30
|
|
|
'Referenced entity id lookup failed: Maximum number of entity visits (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 MaxReferencedEntityVisitsExhaustedException( |
47
|
|
|
$entityId, |
48
|
|
|
$propertyId, |
49
|
|
|
$toIds, |
50
|
|
|
123, |
51
|
|
|
'blah blah', |
52
|
|
|
$previous |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$this->assertSame( 123, $exception->getMaxEntityVisits() ); |
56
|
|
|
$this->assertSame( 'blah blah', $exception->getMessage() ); |
57
|
|
|
$this->assertSame( 0, $exception->getCode() ); |
58
|
|
|
$this->assertSame( $previous, $exception->getPrevious() ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|