Passed
Push — master ( f80f70...56399a )
by Thomas Mauro
03:05 queued 10s
created

RpTestRunner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 20 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClient\ConformanceTest\Runner;
6
7
use PHPUnit\Framework\Assert;
8
use PHPUnit\Framework\IncompleteTestError;
9
use Throwable;
10
use Facile\OpenIDClient\ConformanceTest\Provider\ImplementationProvider;
11
use Facile\OpenIDClient\ConformanceTest\RpTest\RpTestInterface;
12
use Facile\OpenIDClient\ConformanceTest\TestInfo;
13
14
class RpTestRunner
15
{
16
    /** @var ImplementationProvider */
17
    private $implementationProvider;
18
19
    /**
20
     * RpTestRunner constructor.
21
     * @param ImplementationProvider $implementationProvider
22
     */
23
    public function __construct(ImplementationProvider $implementationProvider)
24
    {
25
        $this->implementationProvider = $implementationProvider;
26
    }
27
28
    public function run(RpTestInterface $test, TestInfo $testInfo)
29
    {
30
        $testResult = new RpTestResult(
31
            $test,
32
            $testInfo,
33
            $this->implementationProvider->getCallableCode([$test, 'execute'])
34
        );
35
36
        try {
37
            Assert::resetCount();
38
            $test->execute($testInfo);
39
40
            if (0 === Assert::getCount()) {
41
                throw new IncompleteTestError('There was no assertions in test');
42
            }
43
        } catch (Throwable $e) {
44
            $testResult->setException($e);
45
        }
46
47
        return $testResult;
48
    }
49
}
50