ItemTypeSerializerTest::testSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\Queryr\Serialization;
4
5
use Queryr\Resources\ItemType;
6
use Queryr\Serialization\SerializerFactory;
7
use Wikibase\DataModel\Entity\ItemId;
8
9
/**
10
 * @covers Queryr\Serialization\ItemTypeSerializer
11
 *
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class ItemTypeSerializerTest extends \PHPUnit_Framework_TestCase {
16
17
	public function testGivenNonItemType_exceptionIsThrown() {
18
		$serializer = ( new SerializerFactory() )->newItemTypeSerializer();
19
20
		$this->setExpectedException( 'Serializers\Exceptions\UnsupportedObjectException' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
21
		$serializer->serialize( null );
22
	}
23
24
	public function testSerialize() {
25
		$input = new ItemType();
26
		$input->setLabel( 'City' );
27
		$input->setItemId( new ItemId( 'Q42' ) );
28
		$input->setApiUrl( 'http://api.queryr.com/items/Q42' );
29
		$input->setWikidataUrl( 'http://www.wikidata.org/entity/Q42' );
30
31
		$expected = [
32
			'label' => 'City',
33
			'id' => 'Q42',
34
			'url' => 'http://api.queryr.com/items/Q42',
35
			'wikidata_url' => 'http://www.wikidata.org/entity/Q42',
36
		];
37
38
		$output = ( new SerializerFactory() )->newItemTypeSerializer()->serialize( $input );
39
40
		$this->assertSame( $expected, $output );
41
	}
42
43
}
44