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