QuantityQuerySerializerTest::buildSerializer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
nc 1
cc 1
eloc 2
nop 0
1
<?php
2
3
namespace WikidataQueryApi\Query\Serializers;
4
5
use DataValues\DecimalValue;
6
use Wikibase\DataModel\Entity\PropertyId;
7
use WikidataQueryApi\Query\QuantityQuery;
8
9
/**
10
 * @covers WikidataQueryApi\Query\Serializers\QuantityQuerySerializer
11
 *
12
 * @licence GPLv2+
13
 * @author Thomas Pellissier Tanon
14
 */
15
class QuantityQuerySerializerTest extends SerializerBaseTest {
16
17
	public function buildSerializer() {
18
		return new QuantityQuerySerializer();
19
	}
20
21
	public function serializableProvider() {
22
		return [
23
			[
24
				new QuantityQuery( new PropertyId( 'P42' ), new DecimalValue( '+41' ), new DecimalValue( '+43' ) )
25
			],
26
			[
27
				new QuantityQuery( new PropertyId( 'P42' ), new DecimalValue( '+42' ) )
28
			],
29
		];
30
	}
31
32
	public function nonSerializableProvider() {
33
		return [
34
			[
35
				5
36
			],
37
			[
38
				[]
39
			],
40
			[
41
				new DecimalValue( '+43' )
42
			],
43
		];
44
	}
45
46
	public function serializationProvider() {
47
		return [
48
			[
49
				'quantity[42,+41,+43]',
50
				$query = new QuantityQuery( new PropertyId( 'P42' ), new DecimalValue( '+41' ), new DecimalValue( '+43' ) )
51
			],
52
			[
53
				'quantity[42,+42]',
54
				$query = new QuantityQuery( new PropertyId( 'P42' ), new DecimalValue( '+42' ) )
55
			],
56
		];
57
	}
58
}
59