QuerySerializerTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 0
cbo 7
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 10 1
A serializationProvider() 0 15 1
1
<?php
2
3
namespace WikidataQueryApi\Query\Serializers;
4
5
use DataValues\StringValue;
6
use Wikibase\DataModel\Entity\PropertyId;
7
use WikidataQueryApi\Query\AndQuery;
8
use WikidataQueryApi\Query\StringQuery;
9
10
/**
11
 * @covers WikidataQueryApi\Query\Serializers\QuerySerializer
12
 *
13
 * @licence GPLv2+
14
 * @author Thomas Pellissier Tanon
15
 */
16
class QuerySerializerTest extends SerializerBaseTest {
17
18
	public function buildSerializer() {
19
		return new QuerySerializer( new StringQuerySerializer() );
20
	}
21
22
	public function serializableProvider() {
23
		return [
24
			[
25
				new StringQuery( new PropertyId( 'P42' ), new StringValue( 'foo' ) )
26
			],
27
			[
28
				new AndQuery( [ new StringQuery( new PropertyId( 'P42' ), new StringValue( 'foo' ) ) ] )
29
			],
30
		];
31
	}
32
33
	public function nonSerializableProvider() {
34
		return [
35
			[
36
				5
37
			],
38
			[
39
				[]
40
			],
41
		];
42
	}
43
44
	public function serializationProvider() {
45
		return [
46
			[
47
				'string[42:"foo"]',
48
				new StringQuery( new PropertyId( 'P42' ), new StringValue( 'foo' ) )
49
			],
50
			[
51
				'(string[42:"foo"] AND string[43:"bar"])',
52
				new AndQuery([
53
					new StringQuery( new PropertyId( 'P42' ), new StringValue( 'foo' ) ),
54
					new StringQuery( new PropertyId( 'P43' ), new StringValue( 'bar' ) )
55
				] )
56
			],
57
		];
58
	}
59
}
60