Passed
Push — master ( aa061c...2e1140 )
by Jakub
02:07
created

CollectorTest::testGetEngineName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace MyTester\CodeCoverage;
5
6
use MyTester\Attributes\TestSuite;
7
use MyTester\CodeCoverageException as Exception;
8
use MyTester\TestCase;
9
10
/**
11
 * Test suite for class Collector
12
 *
13
 * @author Jakub Konečný
14
 */
15
#[TestSuite("Code coverage collector")]
16
class CollectorTest extends TestCase
17
{
18
    public function testStart(): void
19
    {
20
        $this->assertThrowsException(function () {
21
            $collector = new Collector();
22
            $collector->start();
23
        }, Exception::class, "No code coverage engine is available.", Exception::NO_ENGINE_AVAILABLE);
24
25
        $collector = new Collector();
26
        $collector->registerEngine(new DummyEngine());
27
        $collector->start();
28
    }
29
30
    public function testFinish(): void
31
    {
32
        $this->assertThrowsException(function () {
33
            $collector = new Collector();
34
            $collector->finish();
35
        }, Exception::class, "Code coverage collector has not been started.", Exception::COLLECTOR_NOT_STARTED);
36
37
        $collector = new Collector();
38
        $collector->registerEngine(new DummyEngine());
39
        $collector->start();
40
        $result = $collector->finish();
41
        $this->assertType("array", $result);
42
    }
43
44
    public function testGetEngineName(): void
45
    {
46
        $this->assertThrowsException(function () {
47
            $collector = new Collector();
48
            $collector->getEngineName();
49
        }, Exception::class, "No code coverage engine is available.", Exception::NO_ENGINE_AVAILABLE);
50
51
        $collector = new Collector();
52
        $collector->registerEngine(new DummyEngine());
53
        $this->assertSame("dummy", $collector->getEngineName());
54
    }
55
}
56