Completed
Push — master ( 5b92bc...3eff9f )
by Jeroen De
02:33
created

IntParamTest::valueProvider()   B

Complexity

Conditions 6
Paths 2

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 8.5559
c 0
b 0
f 0
cc 6
nc 2
nop 1
1
<?php
2
3
namespace ParamProcessor\Tests\Unit\Definitions;
4
5
/**
6
 * @licence GNU GPL v2+
7
 * @author Jeroen De Dauw < [email protected] >
8
 */
9
class IntParamTest extends NumericParamTest {
10
11
	/**
12
	 * @see ParamDefinitionTest::getDefinitions
13
	 * @return array
14
	 */
15
	public function getDefinitions() {
16
		$params = parent::getDefinitions();
17
18
		$params['count'] = [
19
			'type' => 'integer',
20
		];
21
22
		$params['amount'] = [
23
			'type' => 'integer',
24
			'default' => 42,
25
			'upperbound' => 99,
26
		];
27
28
		$params['number'] = [
29
			'type' => 'integer',
30
			'upperbound' => 99,
31
		];
32
33
		return $params;
34
	}
35
36
	/**
37
	 * @see ParamDefinitionTest::valueProvider
38
	 *
39
	 * @param boolean $stringlyTyped
40
	 *
41
	 * @return array
42
	 */
43
	public function valueProvider( $stringlyTyped = true ) {
44
		$values = [
45
			'count' => [
46
				[ 42, true, 42 ],
47
				[ 'foo', false ],
48
				[ 4.2, false ],
49
				[ [ 42 ], false ],
50
			],
51
			'amount' => [
52
				[ 0, true, 0 ],
53
				[ 'foo', false, 42 ],
54
				[ 100, false, 42 ],
55
				[ 4.2, false, 42 ],
56
			],
57
			'number' => [
58
				[ 42, true, 42 ],
59
				[ 'foo', false ],
60
				[ 100, false ],
61
				[ 4.2, false ],
62
			],
63
			'empty' => [
64
				[ 42, true, 42 ],
65
				[ 4.2, false ],
66
				[ [ 42 ], false ],
67
			],
68
			'values' => [
69
				[ 1, true, 1 ],
70
				[ 'yes', false ],
71
				[ true, false ],
72
				[ 0.1, false ],
73
				[ [], false ],
74
			],
75
		];
76
77
		if ( $stringlyTyped ) {
78
			foreach ( $values as &$set ) {
79
				foreach ( $set as &$value ) {
80
					if ( is_float( $value[0] ) || is_int( $value[0] ) ) {
81
						$value[0] = (string)$value[0];
82
					}
83
				}
84
			}
85
		}
86
87
		return $values;
88
	}
89
90
	/**
91
	 * @see ParamDefinitionTest::getType
92
	 * @return string
93
	 */
94
	public function getType() {
95
		return 'integer';
96
	}
97
98
}
99