Completed
Push — master ( 516004...ea0ac9 )
by Robbie
01:45
created

CodeCoverageGoodCheckTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCheck() 0 11 1
A checkProvider() 0 6 1
1
<?php
2
3
namespace SilverStripe\ModuleRatings\Tests\Check;
4
5
use PHPUnit\Framework\TestCase;
6
use SilverStripe\ModuleRatings\Check\CodeCoverageGoodCheck;
7
use SilverStripe\ModuleRatings\Check\CodeCoverageGreatCheck;
8
9
class CodeCoverageGoodCheckTest extends TestCase
10
{
11
    /**
12
     * @covers CodeCoverageGoodCheck::run
13
     * @covers CodeCoverageGreatCheck::run
14
     *
15
     * @param float $coverage
16
     * @param bool $expected
17
     * @dataProvider checkProvider
18
     */
19
    public function testCheck($coverage, $expected)
20
    {
21
        $check = $this->getMockBuilder(CodeCoverageGoodCheck::class)
22
            ->setMethods(['getCoverage'])
23
            ->getMock();
24
25
        $check->expects($this->once())->method('getCoverage')->willReturn($coverage);
26
27
        $check->run();
28
29
        $this->assertSame($expected, $check->getSuccessful());
30
    }
31
32
    /**
33
     * @return array[]
34
     */
35
    public function checkProvider()
36
    {
37
        return [
38
            'low_coverage' => [10, false],
39
            'even_coverage' => [40, true],
40
            'higher_coverage' => [99, true],
41
        ];
42
    }
43
}
44