Passed
Push — master ( 902a34...c826a7 )
by Kyle
53s queued 11s
created

PHPMD/Rule/Design/CountInLoopExpressionTest.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\Design;
19
20
use PHPMD\AbstractTest;
21
22
/**
23
 * Count In Loop Expression Test
24
 *
25
 * @author Kamil Szymanski <[email protected]>
26
 */
27 View Code Duplication
class CountInLoopExpressionTest extends AbstractTest
28
{
29
    /**
30
     * testRuleAppliesToAllTypesOfLoops
31
     *
32
     * @return void
33
     */
34
    public function testRuleAppliesToAllTypesOfLoops()
35
    {
36
        $rule = new CountInLoopExpression();
37
        $rule->setReport($this->getReportMock(3));
0 ignored issues
show
It seems like $this->getReportMock(3) targeting PHPMD\AbstractTest::getReportMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, PHPMD\AbstractRule::setReport() does only seem to accept object<PHPMD\Report>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
38
        $rule->apply($this->getMethod());
39
    }
40
41
    /**
42
     * testRuleNotApplyToExpressionElsewhere
43
     *
44
     * @return void
45
     */
46
    public function testRuleNotApplyToExpressionElsewhere()
47
    {
48
        $rule = new CountInLoopExpression();
49
        $rule->setReport($this->getReportWithNoViolation());
50
        $rule->apply($this->getMethod());
51
    }
52
53
    /**
54
     * testRuleApplyToNestedLoops
55
     *
56
     * @return void
57
     */
58
    public function testRuleApplyToNestedLoops()
59
    {
60
        $rule = new CountInLoopExpression();
61
        $rule->setReport($this->getReportMock(8));
0 ignored issues
show
It seems like $this->getReportMock(8) targeting PHPMD\AbstractTest::getReportMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, PHPMD\AbstractRule::setReport() does only seem to accept object<PHPMD\Report>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
62
        $rule->apply($this->getFunction());
63
    }
64
65
    /**
66
     * testMutedRuleAtClassLevel
67
     *
68
     * @return void
69
     */
70
    public function testMutedRuleAtClassLevel()
71
    {
72
        $rule = new CountInLoopExpression();
73
        $rule->setReport($this->getReportWithNoViolation());
74
        $rule->apply($this->getClass());
75
    }
76
77
    /**
78
     * testMutedRuleAtMethodLevel
79
     *
80
     * @return void
81
     */
82
    public function testMutedRuleAtMethodLevel()
83
    {
84
        $rule = new CountInLoopExpression();
85
        $rule->setReport($this->getReportWithNoViolation());
86
        $rule->apply($this->getClass());
87
    }
88
}
89