diff --git a/flight/Flight.php b/flight/Flight.php index 6e29781..79fef48 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -20,7 +20,6 @@ require_once __DIR__ . '/autoload.php'; * * # Core methods * @method static void start() Starts the framework. - * @method static void path(string $path) Adds a path for autoloading classes. * @method static void stop(?int $code = null) Stops the framework and sends a response. * @method static void halt(int $code = 200, string $message = '', bool $actuallyExit = true) * Stop the framework with an optional status code and message. @@ -129,6 +128,12 @@ class Flight static::__callStatic('unregister', [$methodName]); } + /** Adds a path for autoloading classes. */ + public static function path(string $path): void + { + static::__callStatic('path', [$path]); + } + /** * Handles calls to static methods. * diff --git a/phpunit.xml b/phpunit.xml index c97f669..999dae6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,6 +19,7 @@ tests/ + tests/named-arguments/ diff --git a/tests/named-arguments/ExampleClass.php b/tests/named-arguments/ExampleClass.php new file mode 100644 index 0000000..581551d --- /dev/null +++ b/tests/named-arguments/ExampleClass.php @@ -0,0 +1,5 @@ +status()); + } + + public function test_halt(): void + { + Flight::halt(500, actuallyExit: false, message: 'Test'); + + self::expectOutputString('Test'); + self::assertSame(500, Flight::response()->status()); + } + + ///////////////////// + // ROUTING METHODS // + ///////////////////// + public function test_static_route(): void + { + Flight::request()->url = '/test'; + + $route = Flight::route( + pass_route: true, + alias: 'testRoute', + callback: function () { + echo 'test'; + }, + pattern: '/test' + ); + + self::assertInstanceOf(Route::class, $route); + self::expectOutputString('test'); + Flight::start(); + } +}