Passed
Push — master ( 8ff373...315bd9 )
by adam
01:44
created

BoolParserTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 51
rs 10
c 0
b 0
f 0

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