Code Duplication    Length = 73-73 lines in 2 locations

tests/php/PHPMD/Rule/Design/LongClassTest.php 1 location

@@ 27-99 (lines=73) @@
24
 *
25
 * @covers \PHPMD\Rule\Design\LongClass
26
 */
27
class LongClassTest extends AbstractTest
28
{
29
    /**
30
     * Tests that the rule applies for a value greater than the configured
31
     * threshold.
32
     *
33
     * @return void
34
     */
35
    public function testRuleAppliesForValueGreaterThanThreshold()
36
    {
37
        $class  = $this->getClassMock('loc', 42);
38
        $report = $this->getReportMock(1);
39
40
        $rule = new LongClass();
41
        $rule->setReport($report);
42
        $rule->addProperty('minimum', '41');
43
        $rule->addProperty('ignore-whitespace', false);
44
        $rule->apply($class);
45
    }
46
47
    /**
48
     * Test that the rule applies for a value that is equal with the configured
49
     * threshold.
50
     *
51
     * @return void
52
     */
53
    public function testRuleAppliesForValueEqualToThreshold()
54
    {
55
        $class  = $this->getClassMock('loc', 42);
56
        $report = $this->getReportMock(1);
57
58
        $rule = new LongClass();
59
        $rule->setReport($report);
60
        $rule->addProperty('minimum', '42');
61
        $rule->addProperty('ignore-whitespace', false);
62
        $rule->apply($class);
63
    }
64
65
    /**
66
     * Tests that the rule does not apply when the value is at least one lower
67
     * than the threshold.
68
     *
69
     * @return void
70
     */
71
    public function testRuleDoesNotApplyForValueLowerThanThreshold()
72
    {
73
        $class  = $this->getClassMock('loc', 22);
74
        $report = $this->getReportMock(0);
75
76
        $rule = new LongClass();
77
        $rule->setReport($report);
78
        $rule->addProperty('minimum', '23');
79
        $rule->addProperty('ignore-whitespace', false);
80
        $rule->apply($class);
81
    }
82
83
    /**
84
     * Tests that the rule uses eloc when ignore whitespace is set
85
     *
86
     * @return void
87
     */
88
    public function testRuleUsesElocWhenIgnoreWhitespaceSet()
89
    {
90
        $class  = $this->getClassMock('eloc', 22);
91
        $report = $this->getReportMock(0);
92
93
        $rule = new LongClass();
94
        $rule->setReport($report);
95
        $rule->addProperty('minimum', '23');
96
        $rule->addProperty('ignore-whitespace', true);
97
        $rule->apply($class);
98
    }
99
}
100

tests/php/PHPMD/Rule/Design/LongMethodTest.php 1 location

@@ 27-99 (lines=73) @@
24
 *
25
 * @covers \PHPMD\Rule\Design\LongMethod
26
 */
27
class LongMethodTest extends AbstractTest
28
{
29
    /**
30
     * Tests that the rule applies for a value greater than the configured
31
     * threshold.
32
     *
33
     * @return void
34
     */
35
    public function testRuleAppliesForValueGreaterThanThreshold()
36
    {
37
        $method = $this->getMethodMock('loc', 42);
38
        $report = $this->getReportMock(1);
39
40
        $rule = new LongMethod();
41
        $rule->setReport($report);
42
        $rule->addProperty('minimum', '41');
43
        $rule->addProperty('ignore-whitespace', false);
44
        $rule->apply($method);
45
    }
46
47
    /**
48
     * Test that the rule applies for a value that is equal with the configured
49
     * threshold.
50
     *
51
     * @return void
52
     */
53
    public function testRuleAppliesForValueEqualToThreshold()
54
    {
55
        $method = $this->getMethodMock('loc', 42);
56
        $report = $this->getReportMock(1);
57
58
        $rule = new LongMethod();
59
        $rule->setReport($report);
60
        $rule->addProperty('minimum', '42');
61
        $rule->addProperty('ignore-whitespace', false);
62
        $rule->apply($method);
63
    }
64
65
    /**
66
     * Tests that the rule does not apply when the value is at least one lower
67
     * than the threshold.
68
     *
69
     * @return void
70
     */
71
    public function testRuleDoesNotApplyForValueLowerThanThreshold()
72
    {
73
        $method = $this->getMethodMock('loc', 22);
74
        $report = $this->getReportMock(0);
75
76
        $rule = new LongMethod();
77
        $rule->setReport($report);
78
        $rule->addProperty('minimum', '23');
79
        $rule->addProperty('ignore-whitespace', false);
80
        $rule->apply($method);
81
    }
82
83
    /**
84
     * Tests that the rule uses eloc when ignore whitespace is set
85
     *
86
     * @return void
87
     */
88
    public function testRuleUsesElocWhenIgnoreWhitespaceSet()
89
    {
90
        $class  = $this->getClassMock('eloc', 22);
91
        $report = $this->getReportMock(0);
92
93
        $rule = new LongMethod();
94
        $rule->setReport($report);
95
        $rule->addProperty('minimum', '23');
96
        $rule->addProperty('ignore-whitespace', true);
97
        $rule->apply($class);
98
    }
99
}
100