Simplified tests

pull/532/head
fadrian06 1 year ago
parent 0eac13f4fa
commit 8d6d0f08da

@ -1,20 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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
{

@ -1,21 +1,17 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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

@ -1,19 +1,12 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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';
});

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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']);

@ -1,20 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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';
});

@ -1,18 +1,15 @@
<?php
declare(strict_types=1);
use flight\Engine;
use flight\net\Request;
use flight\net\Response;
use flight\net\Router;
use flight\template\View;
use PHPUnit\Framework\TestCase;
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\core\Loader;
use PHPUnit\Framework\TestCase;

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;

@ -1,22 +1,13 @@
<?php
use flight\database\PdoWrapper;
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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
{

@ -1,15 +1,11 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2013, Mike Cao <mike@mikecao.com>
* @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;

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;

@ -1,15 +1,11 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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;

@ -1,16 +1,12 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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;

@ -1,17 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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;

@ -1,17 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @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);

@ -1,21 +1,17 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @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

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use flight\template\View;
use PHPUnit\Framework\TestCase;
@ -117,7 +119,7 @@ class ViewTest extends TestCase
$this->assertEquals('&lt;script&gt;', $result);
}
public function testENoNeedToEscape()
public function testeNoNeedToEscape()
{
$this->expectOutputString('script');
$result = $this->view->e('script');

@ -1,6 +1,9 @@
<?php
declare(strict_types=1);
$path = file_exists(__DIR__ . '/../vendor/autoload.php')
? __DIR__ . '/../vendor/autoload.php'
: __DIR__ . '/../flight/autoload.php';
require_once($path);

Loading…
Cancel
Save