/
UnresolvedEntityRedirectExceptionTest.php
48 lines (40 loc) · 1.57 KB
/
UnresolvedEntityRedirectExceptionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Wikibase\DataModel\Services\Tests\Lookup;
use Exception;
use PHPUnit_Framework_TestCase;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Services\Lookup\UnresolvedEntityRedirectException;
/**
* @covers Wikibase\DataModel\Services\Lookup\UnresolvedEntityRedirectException
*
* @license GPL-2.0+
* @author Thiemo Kreuz
*/
class UnresolvedEntityRedirectExceptionTest extends PHPUnit_Framework_TestCase {
public function testConstructorWithOnlyRequiredArguments() {
$entityId = new ItemId( 'Q1' );
$redirectTargetId = new ItemId( 'Q2' );
$exception = new UnresolvedEntityRedirectException( $entityId, $redirectTargetId );
$this->assertSame( $entityId, $exception->getEntityId() );
$this->assertSame( $redirectTargetId, $exception->getRedirectTargetId() );
$this->assertSame( 'Unresolved redirect to Q2', $exception->getMessage() );
$this->assertSame( 0, $exception->getCode() );
$this->assertNull( $exception->getPrevious() );
}
public function testConstructorWithAllArguments() {
$entityId = new ItemId( 'Q1' );
$redirectTargetId = new ItemId( 'Q2' );
$previous = new Exception( 'previous' );
$exception = new UnresolvedEntityRedirectException(
$entityId,
$redirectTargetId,
'customMessage',
$previous
);
$this->assertSame( $entityId, $exception->getEntityId() );
$this->assertSame( $redirectTargetId, $exception->getRedirectTargetId() );
$this->assertSame( 'customMessage', $exception->getMessage() );
$this->assertSame( 0, $exception->getCode() );
$this->assertSame( $previous, $exception->getPrevious() );
}
}