Completed
Push — master ( a0c8a1...aee42a )
by Wim
9s
created

InternalInterfacesSniffTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
/**
3
 * Internal Interfaces Sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Internal Interfaces Sniff tests
11
 *
12
 * @uses    BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author  Juliette Reinders Folmer <[email protected]>
15
 */
16
class InternalInterfacesSniffTest 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/internal_interfaces.php');
35
    }
36
37
    /**
38
     * Test Traversable interface
39
     *
40
     * @return void
41
     */
42
    public function testTraversable()
43
    {
44
        $this->assertError($this->_sniffFile, 3, 'The interface Traversable shouldn\'t be implemented directly, implement the Iterator or IteratorAggregate interface instead.');
45
    }
46
47
    /**
48
     * Test DateTimeInterface interface
49
     *
50
     * @return void
51
     */
52
    public function testDateTimeInterface()
53
    {
54
        $this->assertError($this->_sniffFile, 4, 'The interface DateTimeInterface is intended for type hints only and is not implementable.');
55
    }
56
57
    /**
58
     * Test Throwable interface
59
     *
60
     * @return void
61
     */
62
    public function testThrowable()
63
    {
64
        $this->assertError($this->_sniffFile, 5, 'The interface Throwable cannot be implemented directly, extend the Exception class instead.');
65
    }
66
67
    /**
68
     * Test multiple interfaces
69
     *
70
     * @return void
71
     */
72
    public function testMultipleInterfaces()
73
    {
74
        $this->assertError($this->_sniffFile, 7, 'The interface Traversable shouldn\'t be implemented directly, implement the Iterator or IteratorAggregate interface instead.');
75
        $this->assertError($this->_sniffFile, 7, 'The interface Throwable cannot be implemented directly, extend the Exception class instead.');
76
    }
77
78
    /**
79
     * Test interfaces in different cases.
80
     *
81
     * @return void
82
     */
83
    public function testCaseInsensitive()
84
    {
85
        $this->assertError($this->_sniffFile, 9, 'The interface DATETIMEINTERFACE is intended for type hints only and is not implementable.');
86
        $this->assertError($this->_sniffFile, 10, 'The interface datetimeinterface is intended for type hints only and is not implementable.');
87
    }
88
}
89