Passed
Push — master ( e90ce7...2823ca )
by Kyle
02:25 queued 11s
created

testRuleNotAppliesToInterfaceNameAboveThreshold()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 7
loc 7
rs 10
c 0
b 0
f 0
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 cases for ShortClassName rule
24
 *
25
 * @coversDefaultClass \PHPMD\Rule\Naming\ShortClassName
26
 */
27
class ShortClassNameTest extends AbstractTest
28
{
29
    /**
30
     * Tests that rule does not apply to class name length (43) above threshold (43)
31
     *
32
     * @return void
33
     */
34
    public function testRuleNotAppliesToClassNameAboveThreshold()
35
    {
36
        $rule = new ShortClassName();
37
        $rule->addProperty('minimum', 43);
38
        $rule->setReport($this->getReportWithNoViolation());
39
        $rule->apply($this->getClass());
40
    }
41
42
    /**
43
     * Tests that rule applies to class name length (40) below threshold (41)
44
     *
45
     * @return void
46
     */
47 View Code Duplication
    public function testRuleAppliesToClassNameBelowThreshold()
48
    {
49
        $rule = new ShortClassName();
50
        $rule->addProperty('minimum', 41);
51
        $rule->setReport($this->getReportWithOneViolation());
52
        $rule->apply($this->getClass());
53
    }
54
55
    /**
56
     * Tests that rule does not apply to interface name length (47) above threshold (47)
57
     *
58
     * @return void
59
     */
60 View Code Duplication
    public function testRuleNotAppliesToInterfaceNameAboveThreshold()
61
    {
62
        $rule = new ShortClassName();
63
        $rule->addProperty('minimum', 47);
64
        $rule->setReport($this->getReportWithNoViolation());
65
        $rule->apply($this->getInterface());
66
    }
67
68
    /**
69
     * Tests that rule applies for interface name length (44) below threshold (45)
70
     *
71
     * @return void
72
     */
73 View Code Duplication
    public function testRuleAppliesToInterfaceNameBelowThreshold()
74
    {
75
        $rule = new ShortClassName();
76
        $rule->addProperty('minimum', 45);
77
        $rule->setReport($this->getReportWithOneViolation());
78
        $rule->apply($this->getInterface());
79
    }
80
81
    /**
82
     * Tests that rule does not apply for class name length (55) below threshold (61) when set in exceptions
83
     *
84
     * @return void
85
     */
86
    public function testRuleNotAppliesToClassNameBelowThresholdInExceptions()
87
    {
88
        $rule = new ShortClassName();
89
        $rule->addProperty('minimum', 61);
90
        $rule->addProperty('exceptions', 'testRuleNotAppliesToClassNameBelowThresholdInExceptions');
91
        $rule->setReport($this->getReportWithNoViolation());
92
        $rule->apply($this->getClass());
93
    }
94
95
    /**
96
     * Tests that rule applies to class name length (55) below threshold (56) when not set in exceptions
97
     *
98
     * @return void
99
     */
100 View Code Duplication
    public function testRuleAppliesToClassNameBelowThresholdNotInExceptions()
101
    {
102
        $rule = new ShortClassName();
103
        $rule->addProperty('minimum', 56);
104
        $rule->addProperty('exceptions', 'RandomClassName');
105
        $rule->setReport($this->getReportWithOneViolation());
106
        $rule->apply($this->getClass());
107
    }
108
}
109