Completed
Push — merge-sm ( 44b830...c70fa4 )
by Jeroen De
10:03 queued 07:12
created

LineParserTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Maps\Test;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use Maps\Elements\Line;
7
use Maps\LineParser;
8
use ValueParsers\ValueParser;
9
10
/**
11
 * @covers Maps\LineParser
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class LineParserTest extends \ValueParsers\Test\StringValueParserTest {
16
17
	public function setUp() {
18
		if ( !defined( 'MEDIAWIKI' ) ) {
19
			$this->markTestSkipped( 'MediaWiki is not available' );
20
		}
21
	}
22
23
	/**
24
	 * @return string
25
	 */
26
	protected function getParserClass() {
27
		return LineParser::class;
28
	}
29
30
	/**
31
	 * @see ValueParserTestBase::validInputProvider
32
	 *
33
	 * @since 3.0
34
	 *
35
	 * @return array
36
	 */
37
	public function validInputProvider() {
38
		$argLists = [];
39
40
		$valid = [];
41
42
		$valid[] = [
43
			[
44
				42,
45
				4.2
46
			],
47
		];
48
49
		$valid[] = [
50
			[
51
				49.83798245308486,
52
				2.724609375
53
			],
54
			[
55
				52.05249047600102,
56
				8.26171875
57
			],
58
			[
59
				46.37725420510031,
60
				6.15234375
61
			],
62
			[
63
				49.83798245308486,
64
				2.724609375
65
			],
66
		];
67
68
		foreach ( $valid as $values ) {
69
			$input = [];
70
			$output = [];
71
72
			foreach ( $values as $value ) {
73
				$input[] = implode( ',', $value );
74
				$output[] = new LatLongValue( $value[0], $value[1] );
75
			}
76
77
			$input = implode( ':', $input );
78
79
			$argLists[] = [ $input, new Line( $output ) ];
80
		}
81
82
		return $argLists;
83
	}
84
85
	/**
86
	 * @see ValueParserTestBase::requireDataValue
87
	 *
88
	 * @since 3.0
89
	 *
90
	 * @return boolean
91
	 */
92
	protected function requireDataValue() {
93
		return false;
94
	}
95
96
	/**
97
	 * @since 0.1
98
	 *
99
	 * @return ValueParser
100
	 */
101
	protected function getInstance() {
102
		return new LineParser();
103
	}
104
105
}
106