Completed
Push — master ( 5b92bc...3eff9f )
by Jeroen De
02:33
created

OptionsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

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