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
|
|
|
|