1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ParamProcessor\Tests; |
4
|
|
|
|
5
|
|
|
use ParamProcessor\Options; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @covers ParamProcessor\Options |
9
|
|
|
* |
10
|
|
|
* @licence GNU GPL v2+ |
11
|
|
|
* @author Jeroen De Dauw < [email protected] > |
12
|
|
|
*/ |
13
|
|
|
class OptionsTest extends \PHPUnit_Framework_TestCase { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @return Options |
17
|
|
|
*/ |
18
|
|
|
protected function getInstance() { |
19
|
|
|
return new Options(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testBooleanSettersAndGetters() { |
23
|
|
|
$methods = [ |
24
|
|
|
'setUnknownInvalid' => 'unknownIsInvalid', |
25
|
|
|
'setLowercaseNames' => 'lowercaseNames', |
26
|
|
|
'setRawStringInputs' => 'isStringlyTyped', |
27
|
|
|
'setTrimNames' => 'trimNames', |
28
|
|
|
'setTrimValues' => 'trimValues', |
29
|
|
|
'setLowercaseValues' => 'lowercaseValues', |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
foreach ( $methods as $setter => $getter ) { |
33
|
|
|
$options = $this->getInstance(); |
34
|
|
|
|
35
|
|
|
foreach ( [ false, true, false ] as $boolean ) { |
36
|
|
|
call_user_func_array( [ $options, $setter ], [ $boolean ] ); |
37
|
|
|
|
38
|
|
|
$this->assertEquals( $boolean, call_user_func( [ $options, $getter ] ) ); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testSetAndGetName() { |
44
|
|
|
$options = $this->getInstance(); |
45
|
|
|
|
46
|
|
|
foreach ( [ 'foo', 'bar baz' ] as $name ) { |
47
|
|
|
$options->setName( $name ); |
48
|
|
|
$this->assertEquals( $name, $options->getName() ); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
} |
53
|
|
|
|