forked from spryker-shop/b2b-demo-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-autoload.php
47 lines (40 loc) · 1.19 KB
/
test-autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
$autoloader = function ($className) {
$className = ltrim($className, '\\');
$classNameParts = explode('\\', $className);
$filePathPartsSupport = [];
if ($classNameParts[0] === 'PyzTest') {
array_shift($classNameParts);
$application = array_shift($classNameParts);
$bundle = array_shift($classNameParts);
$className = implode(DIRECTORY_SEPARATOR, $classNameParts);
$filePathPartsSupport = [
__DIR__,
'tests',
'PyzTest',
$application,
$bundle,
'_support',
$className . '.php',
];
}
if ($classNameParts[0] === 'PhpStan') {
array_shift($classNameParts);
$className = implode(DIRECTORY_SEPARATOR, $classNameParts);
$filePathPartsSupport = [
__DIR__,
'tests',
'PhpStan',
$className . '.php',
];
}
if ($filePathPartsSupport) {
$filePath = implode(DIRECTORY_SEPARATOR, $filePathPartsSupport);
if (file_exists($filePath)) {
require $filePath;
return true;
}
}
return false;
};
spl_autoload_register($autoloader);