|
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\UnresolvedEntityRedirectException; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @covers Wikibase\DataModel\Services\Lookup\UnresolvedEntityRedirectException |
|
12
|
|
|
* |
|
13
|
|
|
* @licence GNU GPL v2+ |
|
14
|
|
|
* @author Thiemo Mättig |
|
15
|
|
|
*/ |
|
16
|
|
|
class UnresolvedEntityRedirectExceptionTest extends PHPUnit_Framework_TestCase { |
|
17
|
|
|
|
|
18
|
|
|
public function testConstructorWithOnlyRequiredArguments() { |
|
19
|
|
|
$entityId = new ItemId( 'Q1' ); |
|
20
|
|
|
$redirectTargetId = new ItemId( 'Q2' ); |
|
21
|
|
|
$exception = new UnresolvedEntityRedirectException( $entityId, $redirectTargetId ); |
|
22
|
|
|
|
|
23
|
|
|
$this->assertSame( $entityId, $exception->getEntityId() ); |
|
24
|
|
|
$this->assertSame( $redirectTargetId, $exception->getRedirectTargetId() ); |
|
25
|
|
|
$this->assertSame( 'Unresolved redirect to Q2', $exception->getMessage() ); |
|
26
|
|
|
$this->assertSame( 0, $exception->getCode() ); |
|
27
|
|
|
$this->assertNull( $exception->getPrevious() ); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testConstructorWithAllArguments() { |
|
31
|
|
|
$entityId = new ItemId( 'Q1' ); |
|
32
|
|
|
$redirectTargetId = new ItemId( 'Q2' ); |
|
33
|
|
|
$previous = new Exception( 'previous' ); |
|
34
|
|
|
$exception = new UnresolvedEntityRedirectException( |
|
35
|
|
|
$entityId, |
|
36
|
|
|
$redirectTargetId, |
|
37
|
|
|
'customMessage', |
|
38
|
|
|
$previous |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertSame( $entityId, $exception->getEntityId() ); |
|
42
|
|
|
$this->assertSame( $redirectTargetId, $exception->getRedirectTargetId() ); |
|
43
|
|
|
$this->assertSame( 'customMessage', $exception->getMessage() ); |
|
44
|
|
|
$this->assertSame( 0, $exception->getCode() ); |
|
45
|
|
|
$this->assertSame( $previous, $exception->getPrevious() ); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|