From 84cdbcbdc32019f825aa0ebec59aaa3e7a1a4fe4 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Thu, 25 Jan 2024 03:40:46 -0400 Subject: [PATCH] Fixed phpcs format problems in tests --- tests/EngineTest.php | 22 ++++++++++++++-------- tests/RouterTest.php | 19 +++++++++++++++++-- tests/ViewTest.php | 27 +++++++++++++-------------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/tests/EngineTest.php b/tests/EngineTest.php index 012c472..833cbbe 100644 --- a/tests/EngineTest.php +++ b/tests/EngineTest.php @@ -1,8 +1,5 @@ expectOutputString('

404 Not Found

The page you have requested could not be found.

'); + $this->expectOutputString('

404 Not Found

The page you have requested could not be found.

'); $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()); diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 8697a91..12f1543 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -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; diff --git a/tests/ViewTest.php b/tests/ViewTest.php index 4299822..7bd1dd4 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -1,23 +1,15 @@ - * @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);