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

OptionsTest::testConstructor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
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