QuantityQuerySerializerTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 5
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A buildSerializer() 0 3 1
A serializableProvider() 0 10 1
A nonSerializableProvider() 0 13 1
A serializationProvider() 0 12 1
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