Completed
Push — master ( 5b4fcf...5a8d3e )
by Martijn
11s
created

SwaggerGen_TestCase::expectException()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
spl_autoload_register(function($classname) {
4
	$file = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php';
5
	if (is_file($file)) {
6
		require_once $file;
7
	}
8
});
9
10
11
// Unify setting expected exception for different phpunit versions
12
13
// starting with PHPUnit 7.0 `expectException()` needs parameter type-hint
14
// it has to be in a separate file to prevent older php version from choking on scalar parameter type hints
15
// before PHPUnit 6.0 there was `setExpectedException()`
16
// inbetween there was `expectException()` without type hint
17
18
if (class_exists('PHPUnit\Runner\Version')) {
19
	$version = PHPUnit\Runner\Version::id();
20
} else if (class_exists('PHPUnit_Runner_Version')) {
21
	$version = PHPUnit_Runner_Version::id();
22
} else {
23
	throw new Exception('Cannot detect PHPUnit version');
24
}
25
26
if (version_compare($version, '7.0.0', '>=')) {
27
	require dirname(__FILE__) . '/Base/PHPUnit7.php';
28
	class_alias('Base_PHPUnit7', 'SwaggerGen_TestCase');
29
} else if (version_compare($version, '6.0.0', '>=')) {
30
	require dirname(__FILE__) . '/Base/PHPUnit6.php';
31
	class_alias('Base_PHPUnit6', 'SwaggerGen_TestCase');
32
} else {
33
	require dirname(__FILE__) . '/Base/PHPUnit5.php';
34
	class_alias('Base_PHPUnit5', 'SwaggerGen_TestCase');
35
}
36