|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of PHP Mess Detector. |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) Manuel Pichler <[email protected]>. |
|
6
|
|
|
* All rights reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* Licensed under BSD License |
|
9
|
|
|
* For full copyright and license information, please see the LICENSE file. |
|
10
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
11
|
|
|
* |
|
12
|
|
|
* @author Manuel Pichler <[email protected]> |
|
13
|
|
|
* @copyright Manuel Pichler. All rights reserved. |
|
14
|
|
|
* @license https://opensource.org/licenses/bsd-license.php BSD License |
|
15
|
|
|
* @link http://phpmd.org/ |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace PHPMD\Rule\Naming; |
|
19
|
|
|
|
|
20
|
|
|
use PHPMD\AbstractTest; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Test case for the constructor name rule. |
|
24
|
|
|
* |
|
25
|
|
|
* @covers PHPMD\Rule\Naming\ConstantNamingConventions |
|
26
|
|
|
*/ |
|
27
|
|
View Code Duplication |
class ConstantNamingConventionsTest extends AbstractTest |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* testRuleAppliesToClassConstantWithLowerCaseCharacters |
|
31
|
|
|
* |
|
32
|
|
|
* @return void |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testRuleAppliesToClassConstantWithLowerCaseCharacters() |
|
35
|
|
|
{ |
|
36
|
|
|
$rule = new ConstantNamingConventions(); |
|
37
|
|
|
$rule->setReport($this->getReportMock(2)); |
|
38
|
|
|
$rule->apply($this->getClass()); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* testRuleAppliesToInterfaceConstantWithLowerCaseCharacters |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testRuleAppliesToInterfaceConstantWithLowerCaseCharacters() |
|
47
|
|
|
{ |
|
48
|
|
|
$rule = new ConstantNamingConventions(); |
|
49
|
|
|
$rule->setReport($this->getReportMock(3)); |
|
50
|
|
|
$rule->apply($this->getInterface()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* testRuleNotAppliesToClassConstantWithUpperCaseCharacters |
|
55
|
|
|
* |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testRuleNotAppliesToClassConstantWithUpperCaseCharacters() |
|
59
|
|
|
{ |
|
60
|
|
|
$rule = new ConstantNamingConventions(); |
|
61
|
|
|
$rule->setReport($this->getReportMock(0)); |
|
62
|
|
|
$rule->apply($this->getClass()); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* testRuleNotAppliesToInterfaceConstantWithUpperCaseCharacters |
|
67
|
|
|
* |
|
68
|
|
|
* @return void |
|
69
|
|
|
*/ |
|
70
|
|
|
public function testRuleNotAppliesToInterfaceConstantWithUpperCaseCharacters() |
|
71
|
|
|
{ |
|
72
|
|
|
$rule = new ConstantNamingConventions(); |
|
73
|
|
|
$rule->setReport($this->getReportMock(0)); |
|
74
|
|
|
$rule->apply($this->getInterface()); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
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.