Completed
Push — master ( a11ba3...de641c )
by Jeroen De
04:59 queued 02:14
created

OptionsTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 6
c 5
b 0
f 0
lcom 0
cbo 1
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 3 1
A testBooleanSettersAndGetters() 0 20 3
A testSetAndGetName() 0 8 2
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