testGivenUnknownEntityType_getConstructionDiffThrowsException()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\DataModel\Services\Tests\Diff;
4
5
use InvalidArgumentException;
6
use PHPUnit\Framework\TestCase;
7
use RuntimeException;
8
use Wikibase\DataModel\Entity\Item;
9
use Wikibase\DataModel\Entity\Property;
10
use Wikibase\DataModel\Services\Diff\EntityDiffer;
11
use Wikibase\DataModel\Services\Diff\ItemDiff;
12
use Wikibase\DataModel\Services\Fixtures\EntityOfUnknownType;
13
14
/**
15
 * @covers \Wikibase\DataModel\Services\Diff\EntityDiffer
16
 *
17
 * @license GPL-2.0-or-later
18
 * @author Jeroen De Dauw < [email protected] >
19
 */
20
class EntityDifferTest extends TestCase {
21
22
	public function testGivenUnknownEntityType_exceptionIsThrown() {
23
		$differ = new EntityDiffer();
24
25
		$this->expectException( RuntimeException::class );
26
		$differ->diffEntities( new EntityOfUnknownType(), new EntityOfUnknownType() );
27
	}
28
29
	public function testGivenEntitiesWithDifferentTypes_exceptionIsThrown() {
30
		$differ = new EntityDiffer();
31
32
		$this->expectException( InvalidArgumentException::class );
33
		$differ->diffEntities( new Item(), Property::newFromType( 'string' ) );
34
	}
35
36
	public function testGivenTwoEmptyItems_emptyItemDiffIsReturned() {
37
		$differ = new EntityDiffer();
38
39
		$diff = $differ->diffEntities( new Item(), new Item() );
40
41
		$this->assertInstanceOf( ItemDiff::class, $diff );
42
		$this->assertTrue( $diff->isEmpty() );
43
	}
44
45
	public function testGivenUnknownEntityType_getConstructionDiffThrowsException() {
46
		$differ = new EntityDiffer();
47
48
		$this->expectException( RuntimeException::class );
49
		$differ->getConstructionDiff( new EntityOfUnknownType() );
50
	}
51
52
	public function testGivenUnknownEntityType_getDestructionDiffThrowsException() {
53
		$differ = new EntityDiffer();
54
55
		$this->expectException( RuntimeException::class );
56
		$differ->getDestructionDiff( new EntityOfUnknownType() );
57
	}
58
59
}
60