testIsSerializerFor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\EntityStore\DataModel\Serializers;
4
5
use Wikibase\DataModel\Entity\Item;
6
use Wikibase\EntityStore\DataModel\SerializedEntity;
7
8
/**
9
 * @covers Wikibase\EntityStore\DataModel\Serializers\SerializedEntitySerializer
10
 *
11
 * @licence GNU GPL v2+
12
 * @author Thomas Pellissier Tanon
13
 */
14
class SerializedEntitySerializerTest extends \PHPUnit_Framework_TestCase {
15
16
	public function testIsSerializerFor() {
17
		$serializer = new SerializedEntitySerializer();
18
19
		$this->assertTrue( $serializer->isSerializerFor( new SerializedEntity( null, [ 'type' => 'item' ] ) ) );
20
		$this->assertFalse( $serializer->isSerializerFor( null ) );
21
		$this->assertFalse( $serializer->isSerializerFor( new Item() ) );
22
	}
23
24
	public function testSerialize() {
25
		$serializer = new SerializedEntitySerializer();
26
27
		$this->assertEquals(
28
			[ 'type' => 'foo' ],
29
			$serializer->serialize( new SerializedEntity( null, [ 'type' => 'foo' ]))
30
		);
31
	}
32
33
	public function testSerializeThrowException() {
34
		$serializer = new SerializedEntitySerializer();
35
36
		$this->setExpectedException( 'Serializers\Exceptions\UnsupportedObjectException' );
37
		$serializer->serialize( new Item() );
38
	}
39
}
40