PropertyListSerializerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 6
dl 0
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenNonItem_exceptionIsThrown() 0 6 1
A testSerialize() 0 35 1
1
<?php
2
3
namespace Tests\Queryr\Serialization;
4
5
use Queryr\Resources\PropertyList;
6
use Queryr\Resources\PropertyListElement;
7
use Queryr\Serialization\SerializerFactory;
8
use Wikibase\DataModel\Entity\PropertyId;
9
10
/**
11
 * @covers Queryr\Serialization\PropertyListSerializer
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class PropertyListSerializerTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testGivenNonItem_exceptionIsThrown() {
19
		$serializer = ( new SerializerFactory() )->newPropertyListSerializer();
20
21
		$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...
22
		$serializer->serialize( null );
23
	}
24
25
	public function testSerialize() {
26
		$input = new PropertyList( [
27
			new PropertyListElement(
28
				new PropertyId( 'P1' ),
29
				'number',
30
				'http://www.wikidata.org/entity/P1',
31
				'http://api.queryr.com/properties/P1'
32
			),
33
			new PropertyListElement(
34
				new PropertyId( 'P2' ),
35
				'string',
36
				'http://www.wikidata.org/entity/P2',
37
				'http://api.queryr.com/properties/P2'
38
			)
39
		] );
40
41
		$expected = [
42
			[
43
				'id' => 'P1',
44
				'type' => 'number',
45
				'url' => 'http://api.queryr.com/properties/P1',
46
				'wikidata_url' => 'http://www.wikidata.org/entity/P1',
47
			],
48
			[
49
				'id' => 'P2',
50
				'type' => 'string',
51
				'url' => 'http://api.queryr.com/properties/P2',
52
				'wikidata_url' => 'http://www.wikidata.org/entity/P2',
53
			]
54
		];
55
56
		$output = ( new SerializerFactory() )->newPropertyListSerializer()->serialize( $input );
57
58
		$this->assertSame( $expected, $output );
59
	}
60
61
}
62