JsonLdQuantityFormatterTest::validProvider()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 0
1
<?php
2
3
namespace PPP\Wikidata\ValueFormatters\JsonLd;
4
5
use DataValues\DecimalValue;
6
use DataValues\QuantityValue;
7
use ValueFormatters\DecimalFormatter;
8
use ValueFormatters\FormatterOptions;
9
use ValueFormatters\QuantityFormatter;
10
11
/**
12
 * @covers PPP\Wikidata\ValueFormatters\JsonLd\JsonLdQuantityFormatter
13
 *
14
 * @licence AGPLv3+
15
 * @author Thomas Pellissier Tanon
16
 */
17
class JsonLdQuantityFormatterTest extends JsonLdFormatterTestBase {
18
19
	/**T
20
	 * @see JsonLdFormatterTestBase::validProvider
21
	 */
22
	public function validProvider() {
23
		return array(
24
			array(
25
				new QuantityValue(new DecimalValue(1234), '1', new DecimalValue(1235), new DecimalValue(1233.3333)),
26
				(object) array(
27
					'@type' => 'QuantitativeValue',
28
					'name' => '1234.0±1.0',
29
					'value' => (object) array('@type' => 'Integer', '@value' => 1234),
30
					'minValue' => (object) array('@type' => 'Float', '@value' => 1233.3333),
31
					'maxValue' => (object) array('@type' => 'Integer', '@value' => 1235),
32
				)
33
			),
34
			array(
35
				new QuantityValue(new DecimalValue(1234), 'http://www.wikidata.org/entity/Q11573', new DecimalValue(1234), new DecimalValue(1234)),
36
				(object) array(
37
					'@type' => 'QuantitativeValue',
38
					'name' => '1234 m',
39
					'value' => (object) array('@type' => 'Integer', '@value' => 1234),
40
					'minValue' => (object) array('@type' => 'Integer', '@value' => 1234),
41
					'maxValue' => (object) array('@type' => 'Integer', '@value' => 1234),
42
					'unitCode' => 'http://www.wikidata.org/entity/Q11573'
43
				)
44
			),
45
		);
46
	}
47
48
	/**
49
	 * @see JsonLdFormatterTestBase::getInstance
50
	 */
51
	protected function getInstance(FormatterOptions $options = null) {
52
		$vocabularyUriFormatter = $this->getMock('\ValueFormatters\ValueFormatter');
53
		$vocabularyUriFormatter->expects($this->any())
54
			->method('format')
55
			->with($this->equalTo('http://www.wikidata.org/entity/Q11573'))
56
			->will($this->returnValue('m'));
57
58
		return new JsonLdQuantityFormatter(
59
			new QuantityFormatter($options, new DecimalFormatter($options), $vocabularyUriFormatter, '$1 $2'),
60
			new JsonLdDecimalFormatter($options),
61
			$options
62
		);
63
	}
64
}
65