blob: f49f71299411be2565b7c886e167c00309fe9e3e (
plain)
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
|
<?php
declare(strict_types=1);
/**
* Test bootstrap — registers a small PSR-4 autoloader so the library and its
* test fixtures can be loaded without requiring a Composer install. If
* vendor/autoload.php exists (Composer installed), prefer it.
*/
$vendorAutoload = dirname(__DIR__) . '/vendor/autoload.php';
if (is_file($vendorAutoload)) {
require $vendorAutoload;
} else {
spl_autoload_register(static function (string $class): void {
$prefixes = [
'BrettParson\\MiniRoute\\Tests\\' => __DIR__ . '/',
'BrettParson\\MiniRoute\\' => dirname(__DIR__) . '/src/',
];
foreach ($prefixes as $prefix => $baseDir) {
if (!str_starts_with($class, $prefix)) {
continue;
}
$relative = substr($class, strlen($prefix));
$file = $baseDir . str_replace('\\', '/', $relative) . '.php';
if (is_file($file)) {
require $file;
return;
}
}
});
}
|