From 1485540ad9caccdc23c4a9f46e4beb09e610bef2 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Fri, 26 Jan 2024 20:14:44 -0400 Subject: [PATCH 1/6] Added SublimeText PHPCS Build System --- flight.sublime-project | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flight.sublime-project b/flight.sublime-project index e507ffa..ccca03f 100644 --- a/flight.sublime-project +++ b/flight.sublime-project @@ -41,7 +41,12 @@ { "name": "Linter - Default", "quiet": true, - "shell_cmd": "composer lint -- --no-ansi | composer phpcs -- --no-colors", + "shell_cmd": "composer lint -- --no-ansi & composer phpcs -- --no-colors", + }, + { + "name": "PHPCS", + "quiet": true, + "shell_cmd": "composer phpcs -- --no-colors" }, { "name": "Format", From f8a3b841cf531621b8cdb812db71de1139b577a7 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Fri, 26 Jan 2024 20:25:27 -0400 Subject: [PATCH 2/6] Flight and Engine docblocks refactored --- flight/Engine.php | 44 +++++++++++++++++++++++--------------------- flight/Flight.php | 41 +++++++++++++++++++++++++---------------- flight/autoload.php | 7 ------- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/flight/Engine.php b/flight/Engine.php index ac71828..98e6982 100644 --- a/flight/Engine.php +++ b/flight/Engine.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight; @@ -28,36 +21,46 @@ use flight\net\Route; * It is responsible for loading an HTTP request, running the assigned services, * and generating an HTTP response. * - * Core methods + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao * + * # Core methods * @method void start() Starts engine * @method void stop() Stops framework and outputs current response * @method void halt(int $code = 200, string $message = '') Stops processing and returns a given response. * - * Routing - * @method Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a URL to a callback function with all applicable methods - * @method void group(string $pattern, callable $callback, array $group_middlewares = []) Groups a set of routes together under a common prefix. - * @method Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a POST URL to a callback function. - * @method Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PUT URL to a callback function. - * @method Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PATCH URL to a callback function. - * @method Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a DELETE URL to a callback function. + * # Routing + * @method Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a URL to a callback function with all applicable methods + * @method void group(string $pattern, callable $callback, array $group_middlewares = []) + * Groups a set of routes together under a common prefix. + * @method Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a POST URL to a callback function. + * @method Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a PUT URL to a callback function. + * @method Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a PATCH URL to a callback function. + * @method Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a DELETE URL to a callback function. * @method Router router() Gets router * @method string getUrl(string $alias) Gets a url from an alias * - * Views + * # Views * @method void render(string $file, array $data = null, string $key = null) Renders template * @method View view() Gets current view * - * Request-response + * # Request-Response * @method Request request() Gets current request * @method Response response() Gets current response * @method void error(Throwable $e) Sends an HTTP 500 response for any errors. * @method void notFound() Sends an HTTP 404 response when a URL is not found. * @method void redirect(string $url, int $code = 303) Redirects the current request to another URL. - * @method void json(mixed $data, int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSON response. - * @method void jsonp(mixed $data, string $param = 'jsonp', int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSONP response. + * @method void json(mixed $data, int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0) + * Sends a JSON response. + * @method void jsonp(mixed $data, string $param = 'jsonp', int $code = 200, + * bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSONP response. * - * HTTP caching + * # HTTP caching * @method void etag($id, string $type = 'strong') Handles ETag HTTP caching. * @method void lastModified(int $time) Handles last modified HTTP caching. */ @@ -601,7 +604,6 @@ class Engine * * @param int $code HTTP status code * @param string $message Response message - * */ public function _halt(int $code = 200, string $message = ''): void { diff --git a/flight/Flight.php b/flight/Flight.php index b22cf0a..fdff60a 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); use flight\core\Dispatcher; @@ -19,18 +12,29 @@ use flight\net\Route; /** * The Flight class is a static representation of the framework. + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao * + * # 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() Stops the framework and sends a response. - * @method static void halt(int $code = 200, string $message = '') Stop the framework with an optional status code and message. + * @method static void halt(int $code = 200, string $message = '') + * Stop the framework with an optional status code and message. * - * @method static Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Maps a URL pattern to a callback with all applicable methods. - * @method static void group(string $pattern, callable $callback, array $group_middlewares = []) Groups a set of routes together under a common prefix. - * @method static Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a POST URL to a callback function. - * @method static Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PUT URL to a callback function. - * @method static Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PATCH URL to a callback function. - * @method static Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a DELETE URL to a callback function. + * # Routing + * @method static Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Maps a URL pattern to a callback with all applicable methods. + * @method static void group(string $pattern, callable $callback, array $group_middlewares = []) + * Groups a set of routes together under a common prefix. + * @method static Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a POST URL to a callback function. + * @method static Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a PUT URL to a callback function. + * @method static Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a PATCH URL to a callback function. + * @method static Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') + * Routes a DELETE URL to a callback function. * @method static Router router() Returns Router instance. * @method static string getUrl(string $alias) Gets a url from an alias * @@ -44,17 +48,22 @@ use flight\net\Route; * @method static bool has($key) Checks if a variable is set. * @method static void clear($key = null) Clears a variable. * + * # Views * @method static void render($file, array $data = null, $key = null) Renders a template file. * @method static View view() Returns View instance. * + * # Request-Response * @method static Request request() Returns Request instance. * @method static Response response() Returns Response instance. * @method static void redirect($url, $code = 303) Redirects to another URL. - * @method static void json($data, $code = 200, $encode = true, $charset = "utf8", $encodeOption = 0, $encodeDepth = 512) Sends a JSON response. - * @method static void jsonp($data, $param = 'jsonp', $code = 200, $encode = true, $charset = "utf8", $encodeOption = 0, $encodeDepth = 512) Sends a JSONP response. + * @method static void json($data, $code = 200, $encode = true, $charset = "utf8", + * $encodeOption = 0, $encodeDepth = 512) Sends a JSON response. + * @method static void jsonp($data, $param = 'jsonp', $code = 200, $encode = true, + * $charset = "utf8", $encodeOption = 0, $encodeDepth = 512) Sends a JSONP response. * @method static void error($exception) Sends an HTTP 500 response. * @method static void notFound() Sends an HTTP 404 response. * + * # HTTP caching * @method static void etag($id, $type = 'strong') Performs ETag HTTP caching. * @method static void lastModified($time) Performs last modified HTTP caching. */ diff --git a/flight/autoload.php b/flight/autoload.php index 24f9643..3a7ea5a 100644 --- a/flight/autoload.php +++ b/flight/autoload.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); use flight\core\Loader; From 98db908ba5e519dfacd0e15ddddcc5adf4e4fdbb Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Fri, 26 Jan 2024 20:25:47 -0400 Subject: [PATCH 3/6] Added some extra PHPCS rules --- phpcs.xml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 1d75995..815a08c 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,5 +1,8 @@ - + Created with the PHP Coding Standard Generator. http://edorian.github.io/php-coding-standard-generator/ @@ -7,6 +10,26 @@ + + + + + + + + + + + + + + + + + + + + flight/ tests/ From 7015e5d3ba70fda98b4f2a1d3d03a524aab22cd2 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Fri, 26 Jan 2024 20:39:24 -0400 Subject: [PATCH 4/6] Moved copyright and license to a public place :D --- flight/core/Dispatcher.php | 10 +++------- flight/core/Loader.php | 10 +++------- flight/database/PdoWrapper.php | 2 ++ flight/net/Request.php | 10 +++------- flight/net/Response.php | 30 ++++++++++++---------------- flight/net/Route.php | 10 +++------- flight/net/Router.php | 10 +++------- flight/template/View.php | 10 +++------- flight/util/Collection.php | 10 +++------- flight/util/ReturnTypeWillChange.php | 2 ++ phpcs.xml | 1 + 11 files changed, 39 insertions(+), 66 deletions(-) diff --git a/flight/core/Dispatcher.php b/flight/core/Dispatcher.php index 8bd51fa..1f55269 100644 --- a/flight/core/Dispatcher.php +++ b/flight/core/Dispatcher.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\core; @@ -19,6 +12,9 @@ use InvalidArgumentException; * are simply aliases for class methods or functions. The Dispatcher * allows you to hook other functions to an event that can modify the * input parameters and/or the output. + * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao */ class Dispatcher { diff --git a/flight/core/Loader.php b/flight/core/Loader.php index e9ac837..046f8d8 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\core; @@ -19,6 +12,9 @@ use Exception; * a list of reusable class instances and can generate a new class * instances with custom initialization parameters. It also performs * class autoloading. + * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao */ class Loader { diff --git a/flight/database/PdoWrapper.php b/flight/database/PdoWrapper.php index ffa4c0c..87c930e 100644 --- a/flight/database/PdoWrapper.php +++ b/flight/database/PdoWrapper.php @@ -1,5 +1,7 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\net; @@ -18,6 +11,9 @@ use flight\util\Collection; * all the super globals $_GET, $_POST, $_COOKIE, and $_FILES * are stored and accessible via the Request object. * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao + * * The default request properties are: * * - **url** - The URL being requested diff --git a/flight/net/Response.php b/flight/net/Response.php index 247c6b5..7bef496 100644 --- a/flight/net/Response.php +++ b/flight/net/Response.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\net; @@ -17,11 +10,14 @@ use Exception; * The Response class represents an HTTP response. The object * contains the response headers, HTTP status code, and response * body. + * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao */ class Response { /** - * header Content-Length. + * Content-Length header. */ public bool $content_length = true; @@ -312,15 +308,15 @@ class Response \strlen($this->body); } - /** - * Gets the response body - * - * @return string - */ - public function getBody(): string - { - return $this->body; - } + /** + * Gets the response body + * + * @return string + */ + public function getBody(): string + { + return $this->body; + } /** * Gets whether response body was sent. diff --git a/flight/net/Route.php b/flight/net/Route.php index f65910a..bdf5827 100644 --- a/flight/net/Route.php +++ b/flight/net/Route.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\net; @@ -15,6 +8,9 @@ namespace flight\net; * The Route class is responsible for routing an HTTP request to * an assigned callback function. The Router tries to match the * requested URL against a series of URL patterns. + * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao */ class Route { diff --git a/flight/net/Router.php b/flight/net/Router.php index 607942e..6f6300a 100644 --- a/flight/net/Router.php +++ b/flight/net/Router.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\net; @@ -18,6 +11,9 @@ use flight\net\Route; * The Router class is responsible for routing an HTTP request to * an assigned callback function. The Router tries to match the * requested URL against a series of URL patterns. + * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao */ class Router { diff --git a/flight/template/View.php b/flight/template/View.php index d0c5f3b..dfd29ee 100644 --- a/flight/template/View.php +++ b/flight/template/View.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\template; @@ -15,6 +8,9 @@ namespace flight\template; * The View class represents output to be displayed. It provides * methods for managing view data and inserts the data into * view templates upon rendering. + * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao */ class View { diff --git a/flight/util/Collection.php b/flight/util/Collection.php index 3c1317c..0ede58a 100644 --- a/flight/util/Collection.php +++ b/flight/util/Collection.php @@ -1,12 +1,5 @@ - * @license MIT, http://flightphp.com/license - */ - declare(strict_types=1); namespace flight\util; @@ -19,6 +12,9 @@ use JsonSerializable; /** * The Collection class allows you to access a set of data * using both array and object notation. + * + * @license MIT, http://flightphp.com/license + * @copyright Copyright (c) 2011, Mike Cao * @implements ArrayAccess * @implements Iterator */ diff --git a/flight/util/ReturnTypeWillChange.php b/flight/util/ReturnTypeWillChange.php index 982800c..81fb685 100644 --- a/flight/util/ReturnTypeWillChange.php +++ b/flight/util/ReturnTypeWillChange.php @@ -1,5 +1,7 @@ + flight/ tests/ From 0eac13f4fa8d95c18f522b960687b777d701545b Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Fri, 26 Jan 2024 20:41:24 -0400 Subject: [PATCH 5/6] Added Testing helper classes strict types --- tests/classes/Factory.php | 2 ++ tests/classes/Hello.php | 6 ++++-- tests/classes/TesterClass.php | 2 ++ tests/classes/User.php | 6 ++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/classes/Factory.php b/tests/classes/Factory.php index 0d794fc..7ac5c96 100644 --- a/tests/classes/Factory.php +++ b/tests/classes/Factory.php @@ -1,5 +1,7 @@ name = $name; } From 8d6d0f08da4edb1fc5ab3fb717b866b4858e9a4d Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sat, 27 Jan 2024 12:43:52 -0400 Subject: [PATCH 6/6] Simplified tests --- tests/AutoloadTest.php | 15 ++++----------- tests/CollectionTest.php | 20 ++++++++------------ tests/DispatcherTest.php | 15 ++++----------- tests/EngineTest.php | 9 ++------- tests/FilterTest.php | 23 ++++++++--------------- tests/FlightTest.php | 19 ++++++++----------- tests/LoaderTest.php | 7 +------ tests/MapTest.php | 7 +------ tests/PdoWrapperTest.php | 19 +++++-------------- tests/RedirectTest.php | 10 +++------- tests/RegisterTest.php | 7 +------ tests/RenderTest.php | 10 +++------- tests/RequestTest.php | 10 +++------- tests/ResponseTest.php | 14 +++++--------- tests/RouterTest.php | 17 ++++++----------- tests/VariableTest.php | 20 ++++++++------------ tests/ViewTest.php | 4 +++- tests/phpunit_autoload.php | 3 +++ 18 files changed, 76 insertions(+), 153 deletions(-) diff --git a/tests/AutoloadTest.php b/tests/AutoloadTest.php index ff44485..cb35757 100644 --- a/tests/AutoloadTest.php +++ b/tests/AutoloadTest.php @@ -1,20 +1,13 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\Engine; +use PHPUnit\Framework\TestCase; -class AutoloadTest extends PHPUnit\Framework\TestCase +class AutoloadTest extends TestCase { - /** - * @var Engine - */ - private $app; + private Engine $app; protected function setUp(): void { diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 8be746b..124fba2 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -1,21 +1,17 @@ - * @license MIT, http://flightphp.com/license - */ -class CollectionTest extends PHPUnit\Framework\TestCase +declare(strict_types=1); + +use flight\util\Collection; +use PHPUnit\Framework\TestCase; + +class CollectionTest extends TestCase { - /** - * @var \flight\util\Collection - */ - private $collection; + private Collection $collection; protected function setUp(): void { - $this->collection = new \flight\util\Collection(['a' => 1, 'b' => 2]); + $this->collection = new Collection(['a' => 1, 'b' => 2]); } // Get an item diff --git a/tests/DispatcherTest.php b/tests/DispatcherTest.php index cb8edf9..1e10c26 100644 --- a/tests/DispatcherTest.php +++ b/tests/DispatcherTest.php @@ -1,19 +1,12 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\core\Dispatcher; +use PHPUnit\Framework\TestCase; -class DispatcherTest extends PHPUnit\Framework\TestCase +class DispatcherTest extends TestCase { - /** - * @var Dispatcher|null - */ private Dispatcher $dispatcher; protected function setUp(): void @@ -131,7 +124,7 @@ class DispatcherTest extends PHPUnit\Framework\TestCase return "Hello, $name!"; }); - $this->dispatcher->hook('hello', 'before', function (&$params, &$output) { + $this->dispatcher->hook('hello', 'before', function (&$params) { // Manipulate the parameter $params[0] = 'Fred'; }); diff --git a/tests/EngineTest.php b/tests/EngineTest.php index 833cbbe..c4cb109 100644 --- a/tests/EngineTest.php +++ b/tests/EngineTest.php @@ -1,11 +1,6 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\Engine; use flight\net\Response; @@ -263,7 +258,7 @@ class EngineTest extends TestCase $this->assertEquals(200, $engine->response()->status()); } - public function testJsonPBadParam() + public function testJsonpBadParam() { $engine = new Engine(); $engine->jsonp(['key1' => 'value1', 'key2' => 'value2']); diff --git a/tests/FilterTest.php b/tests/FilterTest.php index fbf27e0..4798045 100644 --- a/tests/FilterTest.php +++ b/tests/FilterTest.php @@ -1,20 +1,13 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\Engine; +use PHPUnit\Framework\TestCase; -class FilterTest extends PHPUnit\Framework\TestCase +class FilterTest extends TestCase { - /** - * @var Engine - */ - private $app; + private Engine $app; protected function setUp(): void { @@ -28,7 +21,7 @@ class FilterTest extends PHPUnit\Framework\TestCase return "Hello, $name!"; }); - $this->app->before('hello', function (&$params, &$output) { + $this->app->before('hello', function (&$params) { // Manipulate the parameter $params[0] = 'Fred'; }); @@ -50,15 +43,15 @@ class FilterTest extends PHPUnit\Framework\TestCase return "Bye, $name!"; }); - $this->app->before('bye', function (&$params, &$output) { + $this->app->before('bye', function (&$params) { $params[0] = 'Bob'; }); - $this->app->before('bye', function (&$params, &$output) { + $this->app->before('bye', function (&$params) { $params[0] = 'Fred'; return false; }); - $this->app->before('bye', function (&$params, &$output) { + $this->app->before('bye', function (&$params) { $params[0] = 'Ted'; }); diff --git a/tests/FlightTest.php b/tests/FlightTest.php index 07a7346..90bed34 100644 --- a/tests/FlightTest.php +++ b/tests/FlightTest.php @@ -1,18 +1,15 @@ - * @license MIT, http://flightphp.com/license - */ -class FlightTest extends PHPUnit\Framework\TestCase +class FlightTest extends TestCase { protected function setUp(): void { @@ -79,11 +76,11 @@ class FlightTest extends PHPUnit\Framework\TestCase self::assertIsObject($user); self::assertInstanceOf(User::class, $user); - Flight::unregister('user'); + Flight::unregister('user'); - self::expectException(Exception::class); - self::expectExceptionMessage('user must be a mapped method.'); - $user = Flight::user(); + self::expectException(Exception::class); + self::expectExceptionMessage('user must be a mapped method.'); + $user = Flight::user(); } // Map a function diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index 2ed2be9..e7240b4 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -1,11 +1,6 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\core\Loader; use PHPUnit\Framework\TestCase; diff --git a/tests/MapTest.php b/tests/MapTest.php index dc75b56..1e67c49 100644 --- a/tests/MapTest.php +++ b/tests/MapTest.php @@ -1,11 +1,6 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\Engine; use PHPUnit\Framework\TestCase; diff --git a/tests/PdoWrapperTest.php b/tests/PdoWrapperTest.php index 32c3c99..3543140 100644 --- a/tests/PdoWrapperTest.php +++ b/tests/PdoWrapperTest.php @@ -1,22 +1,13 @@ - * @license MIT, http://flightphp.com/license - */ - +declare(strict_types=1); +use flight\database\PdoWrapper; +use PHPUnit\Framework\TestCase; -class PdoWrapperTest extends PHPUnit\Framework\TestCase +class PdoWrapperTest extends TestCase { - /** - * @var Pdo_Wrapper - */ - private $pdo_wrapper; + private PdoWrapper $pdo_wrapper; protected function setUp(): void { diff --git a/tests/RedirectTest.php b/tests/RedirectTest.php index 758df92..2888b0d 100644 --- a/tests/RedirectTest.php +++ b/tests/RedirectTest.php @@ -1,15 +1,11 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\Engine; +use PHPUnit\Framework\TestCase; -class RedirectTest extends PHPUnit\Framework\TestCase +class RedirectTest extends TestCase { private Engine $app; diff --git a/tests/RegisterTest.php b/tests/RegisterTest.php index 370b1ab..7c51cb0 100644 --- a/tests/RegisterTest.php +++ b/tests/RegisterTest.php @@ -1,11 +1,6 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\Engine; use PHPUnit\Framework\TestCase; diff --git a/tests/RenderTest.php b/tests/RenderTest.php index c49bf53..c030b78 100644 --- a/tests/RenderTest.php +++ b/tests/RenderTest.php @@ -1,15 +1,11 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\Engine; +use PHPUnit\Framework\TestCase; -class RenderTest extends PHPUnit\Framework\TestCase +class RenderTest extends TestCase { private Engine $app; diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 7d31cf2..c11549e 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -1,16 +1,12 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\net\Request; use flight\util\Collection; +use PHPUnit\Framework\TestCase; -class RequestTest extends PHPUnit\Framework\TestCase +class RequestTest extends TestCase { private Request $request; diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index 6d6f129..6b106eb 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -1,17 +1,13 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\net\Request; use flight\net\Response; use flight\util\Collection; +use PHPUnit\Framework\TestCase; -class ResponseTest extends PHPUnit\Framework\TestCase +class ResponseTest extends TestCase { protected function setUp(): void { @@ -177,7 +173,7 @@ class ResponseTest extends PHPUnit\Framework\TestCase 'max-age=0', ] ]; - public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response + public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): self { $this->test_sent_headers[] = $header_string; return $this; @@ -216,7 +212,7 @@ class ResponseTest extends PHPUnit\Framework\TestCase $response = new class extends Response { protected $test_sent_headers = []; - public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response + public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): self { $this->test_sent_headers[] = $header_string; return $this; diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 12f1543..b8f7453 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -1,17 +1,13 @@ - * @license MIT, http://flightphp.com/license - */ +declare(strict_types=1); use flight\core\Dispatcher; use flight\net\Request; use flight\net\Router; +use PHPUnit\Framework\TestCase; -class RouterTest extends PHPUnit\Framework\TestCase +class RouterTest extends TestCase { private Router $router; @@ -43,15 +39,14 @@ class RouterTest extends PHPUnit\Framework\TestCase // Checks if a route was matched with a given output public function check($str = '') { - /* - $route = $this->router->route($this->request); + + /*$route = $this->router->route($this->request); $params = array_values($route->params); $this->assertTrue(is_callable($route->callback)); - call_user_func_array($route->callback, $params); - */ + call_user_func_array($route->callback, $params);*/ $this->routeRequest(); $this->expectOutputString($str); diff --git a/tests/VariableTest.php b/tests/VariableTest.php index 8bc7462..cf46afe 100644 --- a/tests/VariableTest.php +++ b/tests/VariableTest.php @@ -1,21 +1,17 @@ - * @license MIT, http://flightphp.com/license - */ -class VariableTest extends PHPUnit\Framework\TestCase +declare(strict_types=1); + +use flight\Engine; +use PHPUnit\Framework\TestCase; + +class VariableTest extends TestCase { - /** - * @var \flight\Engine - */ - private $app; + private Engine $app; protected function setUp(): void { - $this->app = new \flight\Engine(); + $this->app = new Engine(); } // Set and get a variable diff --git a/tests/ViewTest.php b/tests/ViewTest.php index 7bd1dd4..db25c26 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -1,5 +1,7 @@ assertEquals('<script>', $result); } - public function testENoNeedToEscape() + public function testeNoNeedToEscape() { $this->expectOutputString('script'); $result = $this->view->e('script'); diff --git a/tests/phpunit_autoload.php b/tests/phpunit_autoload.php index 1114632..5bf47da 100644 --- a/tests/phpunit_autoload.php +++ b/tests/phpunit_autoload.php @@ -1,6 +1,9 @@