Completed
Push — master ( cb0578...28965e )
by Jeroen De
07:11 queued 04:27
created

tests/phpunit/Definitions/BoolParamTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace ParamProcessor\Tests\Definitions;
4
5
/**
6
 * @licence GNU GPL v2+
7
 * @author Jeroen De Dauw < [email protected] >
8
 */
9
class BoolParamTest extends ParamDefinitionTest {
10
11
	/**
12
	 * @see ParamDefinitionTest::getDefinitions
13
	 * @return array
14
	 */
15
	public function getDefinitions() {
16
		$params = parent::getDefinitions();
17
18
		return $params;
19
	}
20
21
	/**
22
	 * @see ParamDefinitionTest::valueProvider
23
	 *
24
	 * @param boolean $stringlyTyped
25
	 *
26
	 * @return array
27
	 */
28
	public function valueProvider( $stringlyTyped = true ) {
29
		$values = [
30
			'empty' => [
31
				[ 'yes', true, true ],
32
				[ 'on', true, true ],
33
				[ '1', true, true ],
34
				[ 'no', true, false ],
35
				[ 'off', true, false ],
36
				[ '0', true, false ],
37
				[ 'foobar', false ],
38
				[ '2', false ],
39
				[ [], false ],
40
				[ 42, false ],
41
			],
42
			'values' => [],
43
//			'values' => array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
//				array( '1', true, true ),
45
//				array( 'yes', true, true ),
46
//				array( 'no', false ),
47
//				array( 'foobar', false ),
48
//			),
49
		];
50
51
		if ( !$stringlyTyped ) {
52
			foreach ( $values as &$set ) {
53
				foreach ( $set as &$value ) {
54
					if ( in_array( $value[0], [ 'yes', 'on', '1', '0', 'off', 'no' ], true ) ) {
55
						$value[0] = in_array( $value[0], [ 'yes', 'on', '1' ], true );
56
					}
57
				}
58
			}
59
		}
60
61
		return $values;
62
	}
63
64
	/**
65
	 * @see ParamDefinitionTest::getType
66
	 * @return string
67
	 */
68
	public function getType() {
69
		return 'boolean';
70
	}
71
72
}
73