Completed
Pull Request — master (#47)
by no
05:37 queued 03:01
created

BoolParserTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 7
Bugs 1 Features 2
Metric Value
wmc 4
c 7
b 1
f 2
lcom 0
cbo 3
dl 0
loc 51
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 3 1
A validInputProvider() 0 17 1
A invalidInputProvider() 0 14 2
1
<?php
2
3
namespace ValueParsers\Test;
4
5
use DataValues\BooleanValue;
6
use ValueParsers\BoolParser;
7
8
/**
9
 * @covers ValueParsers\BoolParser
10
 * @covers ValueParsers\StringValueParser
11
 *
12
 * @group ValueParsers
13
 * @group DataValueExtensions
14
 *
15
 * @license GPL-2.0+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class BoolParserTest extends StringValueParserTest {
19
20
	/**
21
	 * @see ValueParserTestBase::getInstance
22
	 *
23
	 * @return BoolParser
24
	 */
25
	protected function getInstance() {
26
		return new BoolParser();
27
	}
28
29
	/**
30
	 * @see ValueParserTestBase::validInputProvider
31
	 */
32
	public function validInputProvider() {
33
		return array(
34
			array( 'yes', new BooleanValue( true ) ),
35
			array( 'on', new BooleanValue( true ) ),
36
			array( '1', new BooleanValue( true ) ),
37
			array( 'true', new BooleanValue( true ) ),
38
			array( 'no', new BooleanValue( false ) ),
39
			array( 'off', new BooleanValue( false ) ),
40
			array( '0', new BooleanValue( false ) ),
41
			array( 'false', new BooleanValue( false ) ),
42
43
			array( 'YeS', new BooleanValue( true ) ),
44
			array( 'ON', new BooleanValue( true ) ),
45
			array( 'No', new BooleanValue( false ) ),
46
			array( 'OfF', new BooleanValue( false ) ),
47
		);
48
	}
49
50
	/**
51
	 * @see StringValueParserTest::invalidInputProvider
52
	 */
53
	public function invalidInputProvider() {
54
		$argLists = parent::invalidInputProvider();
55
56
		$invalid = array(
57
			'foo',
58
			'2',
59
		);
60
61
		foreach ( $invalid as $value ) {
62
			$argLists[] = array( $value );
63
		}
64
65
		return $argLists;
66
	}
67
68
}
69