Passed
Push — master ( 761e95...f1e6ba )
by Jeroen De
05:40
created

NumericParamTest::upperBoundProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ParamProcessor\Tests\Integration\Definitions;
4
5
use ParamProcessor\Options;
6
7
/**
8
 * @licence GNU GPL v2+
9
 * @author Jeroen De Dauw < [email protected] >
10
 */
11
abstract class NumericParamTest extends ParamDefinitionTest {
12
13
	public function lowerBoundProvider() {
14
		return [
15
			[ 42, 42, true ],
16
			[ 42, 41, false ],
17
			[ 42, 43, true ],
18
			[ false, 43, true ],
19
			[ false, 0, true ],
20
			[ false, -100, true ],
21
			[ -100, -100, true ],
22
			[ -99, -100, false ],
23
			[ -101, -100, true ],
24
		];
25
	}
26
27
	/**
28
	 * @dataProvider lowerBoundProvider
29
	 */
30
	public function testSetLowerBound( $bound, $testValue, $validity ) {
31
		$definition = $this->getEmptyInstance();
32
		$definition->setArrayValues( [ 'lowerbound' => $bound ] );
33
34
		$this->validate( $definition, (string)$testValue, $validity );
35
36
		$options = new Options();
37
		$options->setRawStringInputs( false );
38
		$this->validate( $definition, $testValue, $validity, $options );
39
	}
40
41
	public function upperBoundProvider() {
42
		return [
43
			[ 42, 42, true ],
44
			[ 42, 41, true ],
45
			[ 42, 43, false ],
46
			[ false, 43, true ],
47
			[ false, 0, true ],
48
			[ false, -100, true ],
49
			[ -100, -100, true ],
50
			[ -99, -100, true ],
51
			[ -101, -100, false ],
52
		];
53
	}
54
55
	/**
56
	 * @dataProvider upperBoundProvider
57
	 */
58
	public function testSetUpperBound( $bound, $testValue, $validity ) {
59
		$definition = $this->getEmptyInstance();
60
		$definition->setArrayValues( [ 'upperbound' => $bound ] );
61
62
		$this->validate( $definition, (string)$testValue, $validity );
63
64
		$options = new Options();
65
		$options->setRawStringInputs( false );
66
		$this->validate( $definition, $testValue, $validity, $options );
67
	}
68
69
}
70