Completed
Pull Request — master (#38)
by
unknown
02:13
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
// backward compatibility
11
if (!class_exists('PHPUnit\Framework\TestCase') && class_exists('PHPUnit_Framework_TestCase')) {
12
	class_alias('PHPUnit_Framework_TestCase', 'PHPUnit\Framework\TestCase');
13
}
14
15
// Unify setting expected exception for different phpunit versions
16
17
// starting with PHPUnit 7.0 `expectException()` needs parameter type-hint
18
// it has to be in a separate file to prevent older php version from choking on static parameter type hints
19
// before PHPUnit 6.0 there was `setExpectedException()`
20
// inbetween there was `expectException()` without type hint
21
22
if (class_exists('PHPUnit\Runner\Version')) {
23
	$version = PHPUnit\Runner\Version::id();
24
} else if (class_exists('PHPUnit_Runner_Version')) {
25
	$version = PHPUnit_Runner_Version::id();
26
} else {
27
	throw new Exception('Cannot detect PHPUnit version');
28
}
29
30
if (version_compare($version, '7.0.0', '>=')) {
31
	require dirname(__FILE__) . '/Base/PHPUnit7.php';
32
	class_alias('Base_PHPUnit7', 'SwaggerGen_TestCase');
33
} else if (version_compare($version, '6.0.0', '>=')) {
34
	require dirname(__FILE__) . '/Base/PHPUnit6.php';
35
	class_alias('Base_PHPUnit6', 'SwaggerGen_TestCase');
36
} else {
37
	require dirname(__FILE__) . '/Base/PHPUnit5.php';
38
	class_alias('Base_PHPUnit5', 'SwaggerGen_TestCase');
39
}
40