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

tests/phpunit/Definitions/DimensionParamTest.php (2 issues)

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 DimensionParamTest extends ParamDefinitionTest {
10
11
	/**
12
	 * @see ParamDefinitionTest::getDefinitions
13
	 * @return array
14
	 */
15
	public function getDefinitions() {
16
		$params = parent::getDefinitions();
17
18
		$params['auto'] = [
19
			'allowauto' => true,
20
		];
21
22
		$params['allunits'] = [
23
			'units' => [ 'px', 'ex', 'em', '%', '' ],
24
		];
25
26
		$params['bounds'] = [
27
			'lowerbound' => 42,
28
			'upperbound' => 9000,
29
			'maxpercentage' => 34,
30
			'minpercentage' => 23,
31
			'units' => [ 'px', 'ex', '%', '' ],
32
		];
33
34
		return $params;
35
	}
36
37
	/**
38
	 * @see ParamDefinitionTest::valueProvider
39
	 *
40
	 * @param boolean $stringlyTyped
41
	 *
42
	 * @return array
43
	 */
44
	public function valueProvider( $stringlyTyped = true ) {
45
		$values = [
46
			'empty' => [
47
				[ '100px', true, '100px' ],
48
				[ '100', true, '100px' ],
49
				[ 42, true, '42px' ],
50
				[ 42.5, true, '42.5px' ],
51
				[ 'over9000', false ],
52
				[ 'yes', false ],
53
				[ 'auto', false ],
54
				[ '100%', false ],
55
			],
56
			'values' => [
57
				[ 1, true, '1px' ],
58
//				array( 2, false ),
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
59
				[ 'yes', false ],
60
				[ 'no', false ],
61
			],
62
			'auto' => [
63
				[ 'auto', true, 'auto' ],
64
			],
65
			'allunits' => [
66
				[ '100%', true, '100%' ],
67
				[ '100em', true, '100em' ],
68
				[ '100ex', true, '100ex' ],
69
				[ '101%', false ],
70
			],
71
			'bounds' => [
72
				[ '30%', true, '30%' ],
73
				[ '20%', false ],
74
				[ '40%', false ],
75
				[ '100px', true, '100px' ],
76
				[ '100ex', true, '100ex' ],
77
				[ '10px', false ],
78
				[ '9001ex', false ],
79
			],
80
		];
81
82
		if ( $stringlyTyped ) {
83
			foreach ( $values as &$set ) {
84
				foreach ( $set as &$value ) {
85
					if ( is_int( $value[0] ) || is_float( $value[0] ) ) {
86
						$value[0] = (string)$value[0];
87
					}
88
				}
89
			}
90
91
//			$values['empty'][] = array( 42, false );
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
92
//			$values['empty'][] = array( 42.5, false );
93
		}
94
95
		return $values;
96
	}
97
98
	/**
99
	 * @see ParamDefinitionTest::getType
100
	 * @return string
101
	 */
102
	public function getType() {
103
		return 'dimension';
104
	}
105
106
}
107