Passed
Push — feature/issue-718-handle-anony... ( f963d6...3e5eee )
by Kyle
01:51
created

testAppliedToClassesAndMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 6
loc 6
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\CleanCode;
19
20
use PHPMD\AbstractTest;
21
22
/**
23
 * Error Control Operator Test
24
 *
25
 * @coversDefaultClass \PHPMD\Rule\CleanCode\ErrorControlOperator
26
 */
27 View Code Duplication
class ErrorControlOperatorTest extends AbstractTest
28
{
29
    /**
30
     * Tests that the rule does not apply to unary operators in functions
31
     *
32
     * @return void
33
     * @covers ::apply
34
     */
35
    public function testDoesNotApplyToOtherUnaryOperatorsInFunction()
36
    {
37
        $rule = new ErrorControlOperator();
38
        $rule->setReport($this->getReportWithOneViolation());
39
        $rule->apply($this->getFunction());
40
    }
41
42
    /**
43
     * Tests that the rule applies error control operators to functions
44
     *
45
     * @return void
46
     * @covers ::apply
47
     */
48
    public function testAppliesToErrorControlOperatorInFunction()
49
    {
50
        $rule = new ErrorControlOperator();
51
        $rule->setReport($this->getReportMock(3));
0 ignored issues
show
Bug introduced by
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...
52
        $rule->apply($this->getFunction());
53
    }
54
55
    /**
56
     * Tests that the rule applies error control operators to classes and methods
57
     *
58
     * @return void
59
     * @covers ::apply
60
     */
61
    public function testAppliedToClassesAndMethods()
62
    {
63
        $rule = new ErrorControlOperator();
64
        $rule->setReport($this->getReportMock(6));
0 ignored issues
show
Bug introduced by
It seems like $this->getReportMock(6) 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...
65
        $rule->apply($this->getClass());
66
    }
67
}
68