Code Duplication    Length = 18-22 lines in 4 locations

tests/GenericDiffFilterTest.php 1 location

@@ 28-45 (lines=18) @@
25
        $this->assertContains('100.00%', $output);
26
    }
27
28
    public function testMissingHandler()
29
    {
30
        $GLOBALS['argv'] = [
31
            'diffFilter',
32
            __DIR__ . '/fixtures/change.txt',
33
            __DIR__ . '/fixtures/phpcs.json'
34
        ];
35
        try {
36
            ob_start();
37
            require(__DIR__ . "/../src/Runners/generic.php");
38
        } catch (Exception $exception) {
39
            $output = ob_get_clean();
40
            $this->assertContains('--phpcs', $output);
41
            return true;
42
        }
43
44
        $this->fail('Exception not thrown when Expected');
45
    }
46
}
47

tests/PhpmdDiffFilterTest.php 2 locations

@@ 30-49 (lines=20) @@
27
        $this->assertContains('Passed', $output);
28
    }
29
30
    public function testNoValidLines()
31
    {
32
        $GLOBALS['argv'] = [
33
            'diffFilter',
34
            '--phpmd',
35
            __DIR__ . '/fixtures/change.txt',
36
            __DIR__ . '/fixtures/phpmd-change.xml',
37
        ];
38
        try {
39
            ob_start();
40
            require(__DIR__ . "/../src/Runners/generic.php");
41
        } catch (Exception $e) {
42
            $output = ob_get_clean();
43
            $this->assertEquals(2, $e->getCode());
44
            $this->assertContains('0.00%', $output);
45
            return;
46
        }
47
        $this->fail("no exception thrown");
48
    }
49
50
    public function testNoValidLinesStrict()
51
    {
52
        $GLOBALS['argv'] = [
@@ 50-69 (lines=20) @@
47
        $this->fail("no exception thrown");
48
    }
49
50
    public function testNoValidLinesStrict()
51
    {
52
        $GLOBALS['argv'] = [
53
            'diffFilter',
54
            '--phpmdStrict',
55
            __DIR__ . '/fixtures/change.txt',
56
            __DIR__ . '/fixtures/phpmd-change.xml',
57
        ];
58
        try {
59
            ob_start();
60
            require(__DIR__ . "/../src/Runners/generic.php");
61
        } catch (Exception $e) {
62
            $output = ob_get_clean();
63
            $this->assertEquals(2, $e->getCode());
64
            $this->assertContains('0%', $output);
65
            return;
66
        }
67
68
        $this->fail("no exception thrown");
69
    }
70
}
71

tests/PhpCsReflectionTest.php 1 location

@@ 45-66 (lines=22) @@
42
        $this->fail('Exception not thrown when Expected');
43
    }
44
45
    public function testRelatedMethodsFileNotFound()
46
    {
47
        $GLOBALS['argv'] = [
48
            'diffFilter',
49
            '--phpcs',
50
            '--report=json',
51
            __DIR__ . '/fixtures/DocBlocks.txt',
52
            __DIR__ . '/fixtures/DocBlocksNotFound.json'
53
        ];
54
55
        try {
56
            ob_start();
57
            require(__DIR__ . "/../src/Runners/generic.php");
58
        } catch (Exception $exception) {
59
            $output = ob_get_clean();
60
            $this->assertContains("Can't find file", $output);
61
62
            return true;
63
        }
64
65
        $this->fail('Exception not thrown when Expected');
66
    }
67
}
68