Completed
Push — master ( 388143...889690 )
by Thomas
05:32 queued 02:57
created

SerializedEntityTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 7
c 5
b 0
f 0
lcom 1
cbo 3
dl 0
loc 37
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithNoType() 0 4 1
A testGetId() 0 4 1
A testGetNullId() 0 4 1
A testGetType() 0 4 1
A testIsEmptyYes() 0 4 1
A testIsEmptyNo() 0 4 1
A testGetSerialization() 0 4 1
1
<?php
2
3
namespace Wikibase\EntityStore\DataModel;
4
5
use Wikibase\DataModel\Entity\ItemId;
6
7
/**
8
 * @covers Wikibase\EntityStore\DataModel\SerializedEntity
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Thomas Pellissier Tanon
12
 */
13
class SerializedEntityTest extends \PHPUnit_Framework_TestCase {
14
15
	public function testConstructorWithNoType() {
16
		$this->setExpectedException( 'InvalidArgumentException' );
17
		new SerializedEntity( null, [] );
18
	}
19
20
	public function testGetId() {
21
		$entity = new SerializedEntity( new ItemId( 'Q1' ), [ 'type' => 'item' ] );
22
		$this->assertEquals( new ItemId( 'Q1' ), $entity->getId() );
23
	}
24
25
	public function testGetNullId() {
26
		$entity = new SerializedEntity( null, [ 'type' => 'item' ] );
27
		$this->assertEquals( null, $entity->getId() );
28
	}
29
30
	public function testGetType() {
31
		$entity = new SerializedEntity( null, [ 'type' => 'foo' ] );
32
		$this->assertEquals( 'foo', $entity->getType() );
33
	}
34
35
	public function testIsEmptyYes() {
36
		$entity = new SerializedEntity( new ItemId( 'Q1' ), [ 'type' => 'item' ] );
37
		$this->assertTrue( $entity->isEmpty() );
38
	}
39
40
	public function testIsEmptyNo() {
41
		$entity = new SerializedEntity( null, [ 'type' => 'item', 'foo' => 'bar' ] );
42
		$this->assertFalse( $entity->isEmpty() );
43
	}
44
45
	public function testGetSerialization() {
46
		$entity = new SerializedEntity( null, [ 'type' => 'foo' ] );
47
		$this->assertEquals( [ 'type' => 'foo' ], $entity->getSerialization() );
48
	}
49
}
50