Fixed phpcs format problems in tests

pull/531/head
fadrian06 1 year ago
parent 44a056ca30
commit 84cdbcbdc3

@ -1,8 +1,5 @@
<?php
use flight\Engine;
use flight\net\Response;
/**
* Flight: An extensible micro-framework.
*
@ -10,8 +7,11 @@ use flight\net\Response;
* @license MIT, http://flightphp.com/license
*/
use flight\Engine;
use flight\net\Response;
use PHPUnit\Framework\TestCase;
class EngineTest extends PHPUnit\Framework\TestCase
class EngineTest extends TestCase
{
public function setUp(): void
{
@ -22,6 +22,7 @@ class EngineTest extends PHPUnit\Framework\TestCase
{
$_SERVER = [];
}
public function testInitBeforeStart()
{
$engine = new class extends Engine {
@ -123,7 +124,7 @@ class EngineTest extends PHPUnit\Framework\TestCase
echo 'i ran';
return true;
}, true);
$this->expectOutputString('<h1>404 Not Found</h1><h3>The page you have requested could not be found.</h3> ');
$this->expectOutputString('<h1>404 Not Found</h1><h3>The page you have requested could not be found.</h3>');
$engine->start();
}
@ -206,16 +207,21 @@ class EngineTest extends PHPUnit\Framework\TestCase
};
// doing this so we can overwrite some parts of the response
$engine->getLoader()->register('response', function () {
return new class extends \flight\net\Response {
return new class extends Response {
public function __construct()
{
}
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 {
return $this;
}
};
});
$this->expectOutputString('skip---exit');
$engine->halt(500, 'skip---exit');
$this->assertEquals(500, $engine->response()->status());

@ -264,7 +264,21 @@ class RouterTest extends PHPUnit\Framework\TestCase
public function testRouteWithLongQueryParamWithMultilineEncoded()
{
$this->router->map('GET /api/intune/hey', [$this, 'ok']);
$this->request->url = '/api/intune/hey?error=access_denied&error_description=AADSTS65004%3a+User+declined+to+consent+to+access+the+app.%0d%0aTrace+ID%3a+747c0cc1-ccbd-4e53-8e2f-48812eb24100%0d%0aCorrelation+ID%3a+362e3cb3-20ef-400b-904e-9983bd989184%0d%0aTimestamp%3a+2022-09-08+09%3a58%3a12Z&error_uri=https%3a%2f%2flogin.microsoftonline.com%2ferror%3fcode%3d65004&admin_consent=True&state=x2EUE0fcSj#';
$query_params = [
'error=access_denied',
'error_description=AADSTS65004%3a+User+declined+to+consent+to+access+the'
. '+app.%0d%0aTrace+ID%3a+747c0cc1-ccbd-4e53-8e2f-48812eb24100%0d%0a'
. 'Correlation+ID%3a+362e3cb3-20ef-400b-904e-9983bd989184%0d%0a'
. 'Timestamp%3a+2022-09-08+09%3a58%3a12Z',
'error_uri=https%3a%2f%2flogin.microsoftonline.com%2ferror%3fcode%3d65004',
'admin_consent=True',
'state=x2EUE0fcSj#'
];
$query_params = join('&', $query_params);
$this->request->url = "/api/intune/hey?$query_params";
$this->check('OK');
}
@ -406,7 +420,8 @@ class RouterTest extends PHPUnit\Framework\TestCase
public function testResetRoutes()
{
$router = new class extends Router {
$router = new class extends Router
{
public function getIndex()
{
return $this->index;

@ -1,23 +1,15 @@
<?php
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 ViewTest extends PHPUnit\Framework\TestCase
class ViewTest extends TestCase
{
/**
* @var \flight\template\View
*/
private $view;
private View $view;
protected function setUp(): void
{
$this->view = new \flight\template\View();
$this->view = new View();
$this->view->path = __DIR__ . '/views';
}
@ -70,7 +62,13 @@ class ViewTest extends PHPUnit\Framework\TestCase
public function testRenderBadFilePath()
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('Template file not found: ' . __DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'badfile.php');
$exception_message = sprintf(
'Template file not found: %s%sviews%sbadfile.php',
__DIR__,
DIRECTORY_SEPARATOR,
DIRECTORY_SEPARATOR
);
$this->expectExceptionMessage($exception_message);
$this->view->render('badfile');
}
@ -128,7 +126,8 @@ class ViewTest extends PHPUnit\Framework\TestCase
public function testNormalizePath(): void
{
$viewMock = new class extends View {
$viewMock = new class extends View
{
public static function normalizePath(string $path, string $separator = DIRECTORY_SEPARATOR): string
{
return parent::normalizePath($path, $separator);

Loading…
Cancel
Save