Passed
Push — master ( a1ea96...f84f83 )
by Kyle
03:10 queued 11s
created

MissingImportTest::testRuleDoesNotApplyTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
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
 * MissingImport Tests
24
 *
25
 * @coversDefaultClass \PHPMD\Rule\CleanCode\MissingImport
26
 */
27
class MissingImportTest extends AbstractTest
28
{
29
    /**
30
     * Get the rule under test.
31
     *
32
     * @return MissingImport
33
     */
34
    public function getRule()
35
    {
36
        return new MissingImport();
37
    }
38
39
    /**
40
     * Tests the rule for cases where it should apply.
41
     *
42
     * @param string $file The test file to test against.
43
     * @return void
44
     * @dataProvider getApplyingCases
45
     */
46
    public function testRuleAppliesTo($file)
47
    {
48
        $this->expectRuleHasViolationsForFile($this->getRule(), static::ONE_VIOLATION, $file);
49
    }
50
51
    /**
52
     * Tests the rule for cases where it should not apply.
53
     *
54
     * @param string $file The test file to test against.
55
     * @return void
56
     * @dataProvider getNotApplyingCases
57
     */
58
    public function testRuleDoesNotApplyTo($file)
59
    {
60
        $this->expectRuleHasViolationsForFile($this->getRule(), static::NO_VIOLATION, $file);
61
    }
62
63
    /**
64
     * Tests that it applies to a class that has fully qualified class names
65
     *
66
     * @return void
67
     * @covers ::apply
68
     * @covers ::isSelfReference
69
     */
70
    public function testRuleAppliesTwiceToClassWithNotImportedDependencies()
71
    {
72
        $rule = new MissingImport();
73
        $rule->setReport($this->getReportMock(2));
0 ignored issues
show
Bug introduced by
It seems like $this->getReportMock(2) 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...
74
        $rule->apply($this->getMethod());
75
    }
76
}
77