Completed
Pull Request — master (#103)
by
unknown
05:03
created

testMissingMiddleExpression5dot2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
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
    }
35
36
    /**
37
     * Test ternary operators that are acceptable in all PHP versions.
38
     *
39
     * @return void
40
     */
41
    public function testStandardTernaryOperators()
42
    {
43
        $this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php');
44
        $this->assertNoViolation($this->_sniffFile, 5);
45
    }
46
47
    /**
48
     * 5.2 doesn't support elvis operator.
49
     *
50
     * @return void
51
     */
52
    public function testMissingMiddleExpression5dot2()
53
    {
54
        $this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php', '5.2');
55
        $this->assertWarning($this->_sniffFile, 8,
56
                "Middle may not be omitted from ternary operators in PHP < 5.3");
57
    }
58
59
    /**
60
     * 5.3 does support elvis operator.
61
     *
62
     * @return void
63
     */
64
    public function testMissingMiddleExpression5dot3()
65
    {
66
        $this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php', '5.3');
67
        $this->assertNoViolation($this->_sniffFile, 8,
68
                "Middle may not be omitted from ternary operators in PHP < 5.3");
69
    }
70
71
}
72