diff --git a/flight/autoload.php b/flight/autoload.php index 0b0e767..9ae0c69 100644 --- a/flight/autoload.php +++ b/flight/autoload.php @@ -9,6 +9,7 @@ require_once __DIR__ . '/core/Loader.php'; if (file_exists(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; + Loader::autoload(true); +} else { + Loader::autoload(true, [dirname(__DIR__)]); } - -Loader::autoload(true, [dirname(__DIR__)]); diff --git a/tests/AutoloadTest.php b/tests/AutoloadTest.php index 7d8959a..a6ad863 100644 --- a/tests/AutoloadTest.php +++ b/tests/AutoloadTest.php @@ -5,9 +5,11 @@ declare(strict_types=1); namespace tests; use Flight; +use flight\core\Loader; use flight\Engine; use tests\classes\User; use PHPUnit\Framework\TestCase; +use ReflectionClass; class AutoloadTest extends TestCase { @@ -19,6 +21,17 @@ class AutoloadTest extends TestCase $this->app->path(__DIR__ . '/classes'); } + protected function tearDown(): void + { + $dirsProperty = (new ReflectionClass(Loader::class))->getProperty('dirs'); + + if (PHP_VERSION_ID < 80100) { + $dirsProperty->setAccessible(true); + } + + $dirsProperty->setValue(null, []); + } + // Autoload a class public function testAutoload(): void {