Passed
Push — master ( 9acfaa...693f5f )
by Jakub
01:54
created

CollectorTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 18
c 1
b 0
f 1
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFinish() 0 12 1
A testStart() 0 10 1
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