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
|
<?php
namespace ParamProcessor\Tests;
use ParamProcessor\Options;
use PHPUnit\Framework\TestCase;
/**
* @covers \ParamProcessor\Options
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class OptionsTest extends TestCase {
protected function getInstance() {
return new Options();
}
public function testBooleanSettersAndGetters() {
$methods = [
'setUnknownInvalid' => 'unknownIsInvalid',
'setLowercaseNames' => 'lowercaseNames',
'setRawStringInputs' => 'isStringlyTyped',
'setTrimNames' => 'trimNames',
'setTrimValues' => 'trimValues',
'setLowercaseValues' => 'lowercaseValues',
];
foreach ( $methods as $setter => $getter ) {
$options = $this->getInstance();
foreach ( [ false, true, false ] as $boolean ) {
call_user_func_array( [ $options, $setter ], [ $boolean ] );
$this->assertEquals( $boolean, call_user_func( [ $options, $getter ] ) );
}
}
}
public function testSetAndGetName() {
$options = $this->getInstance();
foreach ( [ 'foo', 'bar baz' ] as $name ) {
$options->setName( $name );
$this->assertEquals( $name, $options->getName() );
}
}
}
|