NumericParamTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 59
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A lowerBoundProvider() 0 13 1
A testSetLowerBound() 0 10 1
A upperBoundProvider() 0 13 1
A testSetUpperBound() 0 10 1
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 );
0 ignored issues
show
Deprecated Code introduced by
The method ParamProcessor\Options::setRawStringInputs() has been deprecated with message: since 1.7

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
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 );
0 ignored issues
show
Deprecated Code introduced by
The method ParamProcessor\Options::setRawStringInputs() has been deprecated with message: since 1.7

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
66
		$this->validate( $definition, $testValue, $validity, $options );
67
	}
68
69
}
70