correct unit test and removed final keywords

pull/524/head v3.1.1
n0nag0n 1 year ago
parent 8d20c002c8
commit 1e4c07da52

@ -61,9 +61,18 @@ class Flight
{
/**
* Framework engine.
*
* @var Engine $engine
*/
private static Engine $engine;
/**
* Whether or not the app has been initialized
*
* @var boolean
*/
private static bool $initialized = false;
/**
* Don't allow object instantiation
*
@ -98,7 +107,7 @@ class Flight
* @param ?Closure(T $instance): void $callback Perform actions with the instance
* @return void
*/
static function register($name, $class, $params = [], $callback = null)
public static function register($name, $class, $params = [], $callback = null)
{
static::__callStatic('register', func_get_args());
}
@ -125,14 +134,12 @@ class Flight
*/
public static function app(): Engine
{
static $initialized = false;
if (!$initialized) {
if (!self::$initialized) {
require_once __DIR__ . '/autoload.php';
self::setEngine(new Engine());
$initialized = true;
self::$initialized = true;
}
return self::$engine;

@ -43,7 +43,7 @@ class Dispatcher
*
* @return mixed|null Output of callback
*/
final public function run(string $name, array $params = [])
public function run(string $name, array $params = [])
{
$output = '';
@ -70,7 +70,7 @@ class Dispatcher
* @param string $name Event name
* @param callable $callback Callback function
*/
final public function set(string $name, callable $callback): void
public function set(string $name, callable $callback): void
{
$this->events[$name] = $callback;
}
@ -82,7 +82,7 @@ class Dispatcher
*
* @return callable $callback Callback function
*/
final public function get(string $name): ?callable
public function get(string $name): ?callable
{
return $this->events[$name] ?? null;
}
@ -94,7 +94,7 @@ class Dispatcher
*
* @return bool Event status
*/
final public function has(string $name): bool
public function has(string $name): bool
{
return isset($this->events[$name]);
}
@ -105,7 +105,7 @@ class Dispatcher
*
* @param string|null $name Event name
*/
final public function clear(?string $name = null): void
public function clear(?string $name = null): void
{
if (null !== $name) {
unset($this->events[$name]);
@ -123,7 +123,7 @@ class Dispatcher
* @param string $type Filter type
* @param callable $callback Callback function
*/
final public function hook(string $name, string $type, callable $callback): void
public function hook(string $name, string $type, callable $callback): void
{
$this->filters[$name][$type][] = $callback;
}
@ -137,7 +137,7 @@ class Dispatcher
*
* @throws Exception
*/
final public function filter(array $filters, array &$params, &$output): void
public function filter(array $filters, array &$params, &$output): void
{
$args = [&$params, &$output];
foreach ($filters as $callback) {
@ -204,7 +204,7 @@ class Dispatcher
/**
* Resets the object to the initial state.
*/
final public function reset(): void
public function reset(): void
{
$this->events = [];
$this->filters = [];

@ -37,7 +37,7 @@ use flight\util\Collection;
* - **accept** - HTTP accept parameters
* - **proxy_ip** - Proxy IP address of the client
*/
final class Request
class Request
{
/**
* @var string URL being requested

@ -15,7 +15,7 @@ namespace flight\net;
* an assigned callback function. The Router tries to match the
* requested URL against a series of URL patterns.
*/
final class Route
class Route
{
/**
* @var string URL pattern

@ -21,7 +21,7 @@ use JsonSerializable;
* @implements ArrayAccess<string, mixed>
* @implements Iterator<string, mixed>
*/
final class Collection implements ArrayAccess, Iterator, Countable, JsonSerializable
class Collection implements ArrayAccess, Iterator, Countable, JsonSerializable
{
/**
* Collection data.

@ -227,7 +227,7 @@ class EngineTest extends PHPUnit\Framework\TestCase
public function testEtagSimple() {
$engine = new Engine();
$engine->etag('etag');
$this->assertEquals('etag', $engine->response()->headers()['ETag']);
$this->assertEquals('"etag"', $engine->response()->headers()['ETag']);
}
public function testEtagWithHttpIfNoneMatch() {
@ -241,7 +241,7 @@ class EngineTest extends PHPUnit\Framework\TestCase
};
$_SERVER['HTTP_IF_NONE_MATCH'] = 'etag';
$engine->etag('etag');
$this->assertEquals('etag', $engine->response()->headers()['ETag']);
$this->assertEquals('"etag"', $engine->response()->headers()['ETag']);
$this->assertEquals(304, $engine->response()->status());
}

Loading…
Cancel
Save