Completed
Pull Request — master (#10)
by Scott
02:02
created

PhpcpdTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use PHPUnit\Framework\TestCase;
5
use exussum12\CoverageChecker\Phpcpd;
6
7
class PhpcpdTest extends TestCase
8
{
9
    /** @var  Phpcpd */
10
    protected $cpd;
11
    protected function setUp()
12
    {
13
        parent::setUp();
14
        $this->cpd = new Phpcpd(__DIR__ . '/fixtures/phpcpd.txt');
15
    }
16
17
    public function testOutput()
18
    {
19
20
        $file1 = '/home/user/code/coverageChecker/vendor/symfony/console/Tests/Helper/SymfonyQuestionHelperTest.php';
21
        $file2 = '/home/user/code/coverageChecker/vendor/symfony/console/Tests/Helper/QuestionHelperTest.php';
22
        $expected = [
23
            $file1 => [
24
                45 => ["Duplicate of $file2:58-60"],
25
                46 => ["Duplicate of $file2:58-60"],
26
                47 => ["Duplicate of $file2:58-60"],
27
            ],
28
            $file2 => [
29
                58 => ["Duplicate of $file1:45-47"],
30
                59 => ["Duplicate of $file1:45-47"],
31
                60 => ["Duplicate of $file1:45-47"],
32
            ],
33
        ];
34
35
        $this->assertEquals($expected, $this->cpd->getLines());
36
        $this->assertFalse($this->cpd->isValidLine($file1, 45));
37
        $this->assertTrue($this->cpd->isValidLine($file1, 49));
38
    }
39
40
    public function testNotFoundFile()
41
    {
42
        $this->assertTrue($this->cpd->handleNotFoundFile());
43
    }
44
}
45