1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Extended class name determination test file |
4
|
|
|
* |
5
|
|
|
* @package PHPCompatibility |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Extended class name determination function tests |
11
|
|
|
* |
12
|
|
|
* @uses BaseSniffTest |
13
|
|
|
* @package PHPCompatibility |
14
|
|
|
*/ |
15
|
|
View Code Duplication |
class GetFQExtendedClassNameTest extends BaseAbstractClassMethodTest |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
public $filename = 'sniff-examples/utility-functions/get_fqextended_classname.php'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* testGetFQExtendedClassName |
22
|
|
|
* |
23
|
|
|
* @requires PHP 5.3 |
24
|
|
|
* |
25
|
|
|
* @group utilityFunctions |
26
|
|
|
* |
27
|
|
|
* @dataProvider dataGetFQExtendedClassName |
28
|
|
|
* |
29
|
|
|
* @param int $stackPtr Stack pointer for a T_CLASS token in the test file. |
30
|
|
|
* @param string $expected The expected fully qualified class name. |
31
|
|
|
*/ |
32
|
|
|
public function testGetFQExtendedClassName($stackPtr, $expected) { |
33
|
|
|
$result = $this->helperClass->getFQExtendedClassName($this->_phpcsFile, $stackPtr); |
34
|
|
|
$this->assertSame($expected, $result); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* dataGetFQExtendedClassName |
39
|
|
|
* |
40
|
|
|
* @see testGetFQExtendedClassName() |
41
|
|
|
* |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
|
|
public function dataGetFQExtendedClassName() |
45
|
|
|
{ |
46
|
|
|
return array( |
47
|
|
|
array(7, '\MyTesting\DateTime'), |
48
|
|
|
array(18, '\DateTime'), |
49
|
|
|
array(30, '\MyTesting\anotherNS\DateTime'), |
50
|
|
|
array(43, '\FQNS\DateTime'), |
51
|
|
|
array(65, '\AnotherTesting\DateTime'), |
52
|
|
|
array(77, '\DateTime'), |
53
|
|
|
array(90, '\AnotherTesting\anotherNS\DateTime'), |
54
|
|
|
array(104, '\FQNS\DateTime'), |
55
|
|
|
array(121, '\DateTime'), |
56
|
|
|
array(132, '\DateTime'), |
57
|
|
|
array(155, '\Yet\More\Testing\DateTime'), |
58
|
|
|
array(166, '\Yet\More\Testing\anotherNS\DateTime'), |
59
|
|
|
array(179, '\FQNS\DateTime'), |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.