|
|
|
@ -4,9 +4,12 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
|
|
namespace tests;
|
|
|
|
namespace tests;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Flight;
|
|
|
|
|
|
|
|
use flight\core\Loader;
|
|
|
|
use flight\Engine;
|
|
|
|
use flight\Engine;
|
|
|
|
use tests\classes\User;
|
|
|
|
use tests\classes\User;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
use ReflectionClass;
|
|
|
|
|
|
|
|
|
|
|
|
class AutoloadTest extends TestCase
|
|
|
|
class AutoloadTest extends TestCase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -18,6 +21,17 @@ class AutoloadTest extends TestCase
|
|
|
|
$this->app->path(__DIR__ . '/classes');
|
|
|
|
$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
|
|
|
|
// Autoload a class
|
|
|
|
public function testAutoload(): void
|
|
|
|
public function testAutoload(): void
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -44,4 +58,17 @@ class AutoloadTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
self::assertNull($test);
|
|
|
|
self::assertNull($test);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Flight::path() must load namespaced classes that Composer PSR-4 does not map
|
|
|
|
|
|
|
|
public function testPathAutoloadsNamespacedClassOutsideComposerPsr4(): void
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$class = \app\middleware\Something::class;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self::assertFalse(class_exists($class));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Flight::path(__DIR__ . '/path_autoload_fixtures');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self::assertTrue(class_exists($class));
|
|
|
|
|
|
|
|
self::assertTrue(class_exists(Engine::class));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|