Completed
Pull Request — master (#206)
by Juliette
05:19
created

GetFQClassNameFromDoubleColonTokenTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 55
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetFQClassNameFromDoubleColonToken() 0 4 1
B dataGetFQClassNameFromDoubleColonToken() 0 24 1
1
<?php
2
/**
3
 * Classname determination test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Classname determination from double colon token function tests
11
 *
12
 * @uses    BaseAbstractClassMethodTest
13
 * @package PHPCompatibility
14
 */
15
class GetFQClassNameFromDoubleColonTokenTest extends BaseAbstractClassMethodTest
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...
16
{
17
18
    public $filename = 'sniff-examples/utility-functions/get_fqclassname_from_double_colon_token.php';
19
20
    /**
21
     * testGetFQClassNameFromDoubleColonToken
22
     *
23
     * @group utilityFunctions
24
     *
25
     * @requires PHP 5.3
26
     *
27
     * @dataProvider dataGetFQClassNameFromDoubleColonToken
28
     *
29
     * @param int    $stackPtr Stack pointer for a T_DOUBLE_COLON token in the test file.
30
     * @param string $expected The expected fully qualified class name.
31
     */
32
    public function testGetFQClassNameFromDoubleColonToken($stackPtr, $expected) {
33
        $result = $this->helperClass->getFQClassNameFromDoubleColonToken($this->_phpcsFile, $stackPtr);
34
        $this->assertSame($expected, $result);
35
    }
36
37
    /**
38
     * dataGetFQClassNameFromDoubleColonToken
39
     *
40
     * @see testGetFQClassNameFromDoubleColonToken()
41
     *
42
     * @return array
43
     */
44
    public function dataGetFQClassNameFromDoubleColonToken()
45
    {
46
        return array(
47
            array(3, '\DateTime'),
48
            array(8, '\DateTime'),
49
            array(13, '\DateTime'),
50
            array(21, '\DateTime'),
51
            array(30, '\DateTime'),
52
            array(39, '\AnotherNS\DateTime'),
53
            array(49, '\FQNS\DateTime'),
54
            array(61, '\DateTime'),
55
            array(76, '\AnotherNS\DateTime'),
56
            array(90, '\Testing\DateTime'),
57
            array(96, '\Testing\DateTime'),
58
            array(102, '\Testing\DateTime'),
59
            array(127, '\Testing\MyClass'),
60
            array(135, ''),
61
            array(141, ''),
62
            array(173, '\MyClass'),
63
            array(181, ''),
64
            array(187, ''),
65
            array(247, ''),
66
        );
67
    }
68
69
}
70