Test Failed
Push — master ( a24517...57a539 )
by Fabian
02:46
created

EnhancedTestCase::expectException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace LE_ACME2Tests;
4
5
use PHPUnit;
6
7
class EnhancedTestCase extends PHPUnit\Framework\TestCase {
8
9
    protected function catchExpectedException(string $exception, \Closure $callback) : \Exception {
10
11
        try {
12
            $callback();
13
        } catch (\Exception $e) {
14
            $this->assertEquals(
15
                $exception,
16
                get_class($e),
17
                'Exception message: ' . $e->getMessage(),
18
            );
19
            return $e;
20
        }
21
22
        throw new \RuntimeException('Expected exception not thrown: ' . $exception);
23
    }
24
}