Completed
Pull Request — master (#149)
by Juliette
02:28
created

testMissingMiddleExpression5dot2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    /**
19
     * Sniffed file
20
     *
21
     * @var PHP_CodeSniffer_File
22
     */
23
    protected $_sniffFile;
24
25
    /**
26
     * Test ternary operators that are acceptable in all PHP versions.
27
     *
28
     * @return void
29
     */
30
    public function testStandardTernaryOperators()
31
    {
32
        $this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php');
33
        $this->assertNoViolation($this->_sniffFile, 5);
34
    }
35
36
    /**
37
     * 5.2 doesn't support elvis operator.
38
     *
39
     * @return void
40
     */
41
    public function testMissingMiddleExpression5dot2()
42
    {
43
        $this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php', '5.2');
44
        $this->assertWarning($this->_sniffFile, 8,
45
                "Middle may not be omitted from ternary operators in PHP < 5.3");
46
    }
47
48
    /**
49
     * 5.3 does support elvis operator.
50
     *
51
     * @return void
52
     */
53
    public function testMissingMiddleExpression5dot3()
54
    {
55
        $this->_sniffFile = $this->sniffFile('sniff-examples/ternary_operator.php', '5.3');
56
        $this->assertNoViolation($this->_sniffFile, 8,
57
                "Middle may not be omitted from ternary operators in PHP < 5.3");
58
    }
59
60
}
61