Completed
Push — master ( 4ecb83...b1425f )
by Wim
03:25 queued 01:05
created

testMissingMiddleExpression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4286
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/**
3
 * Ternary Operators Sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Ternary Operators Sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Jansen Price <[email protected]>
15
 */
16
class TernaryOperatorsSniffTest extends BaseSniffTest
17
{
18
    /**
19
     * Sniffed file
20
     *
21
     * @var PHP_CodeSniffer_File
22
     */
23
    protected $_sniffFile;
24
25
    /**
26
     * setUp
27
     *
28
     * @return void
29
     */
30
    public function setUp()
31
    {
32
        parent::setUp();
33
34
        $this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php');
35
    }
36
37
    /**
38
     * Test ternary operators that are acceptable in all PHP versions.
39
     *
40
     * @return void
41
     */
42
    public function testStandardTernaryOperators()
43
    {
44
        $this->assertNoViolation($this->_sniffFile, 5);
45
    }
46
47
    /**
48
     * testHttpGetVars
49
     *
50
     * @return void
51
     */
52
    public function testMissingMiddleExpression()
53
    {
54
        global $Foo;
55
        $Foo = true;
56
        $this->assertWarning($this->_sniffFile, 8,
57
                "Middle may not be omitted from ternary operators in PHP < 5.3");
58
        $Foo = false;
59
    }
60
61
}
62