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
|
|
|
|