TestCoverageTest::testCoverageLow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Hook\PHP\Action;
13
14
use CaptainHook\App\Config;
15
use CaptainHook\App\Console\IO\NullIO;
16
use CaptainHook\App\Mockery;
17
use Exception;
18
use PHPUnit\Framework\TestCase;
19
20
class TestCoverageTest extends TestCase
21
{
22
    use Mockery;
23
24
    public function testCoverageViaCloverXML(): void
25
    {
26
        if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
27
            $this->markTestSkipped('not tested on windows');
28
        }
29
30
        $io       = new NullIO();
31
        $config   = new Config(CH_PATH_FILES . '/captainhook.json');
32
        $repo     = $this->createRepositoryMock();
33
        $standard = new TestCoverage();
34
        $action   = new Config\Action(
35
            TestCoverage::class,
36
            ['cloverXml' => CH_PATH_FILES . '/coverage/valid.xml']
37
        );
38
        $standard->execute($config, $io, $repo, $action);
39
40
        $this->assertTrue(true);
41
    }
42
43
    public function testCoverageLow(): void
44
    {
45
        $this->expectException(Exception::class);
46
47
        $io       = new NullIO();
48
        $config   = new Config(CH_PATH_FILES . '/captainhook.json');
49
        $repo     = $this->createRepositoryMock();
50
        $standard = new TestCoverage();
51
        $action   = new Config\Action(
52
            TestCoverage::class,
53
            [
54
                'cloverXml'   => CH_PATH_FILES . '/coverage/valid.xml',
55
                'minCoverage' => 100
56
            ]
57
        );
58
        $standard->execute($config, $io, $repo, $action);
59
    }
60
61
    public function testCoverageViaPHPUnit(): void
62
    {
63
        if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
64
            $this->markTestSkipped('not tested on windows');
65
        }
66
67
        $io       = new NullIO();
68
        $config   = new Config(CH_PATH_FILES . '/captainhook.json');
69
        $repo     = $this->createRepositoryMock();
70
        $standard = new TestCoverage();
71
        $action   = new Config\Action(
72
            TestCoverage::class,
73
            ['phpUnit' => CH_PATH_FILES . '/bin/phpunit']
74
        );
75
        $standard->execute($config, $io, $repo, $action);
76
77
        $this->assertTrue(true);
78
    }
79
}
80