Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 named arguments support #548

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
},
"autoload-dev": {
"classmap": [
"tests/classes/User.php",
"tests/classes/Hello.php",
"tests/classes/Factory.php",
"tests/classes/TesterClass.php"
]
"tests/classes/"
],
"psr-4": {
"Tests\\PHP8\\": ["tests/named-arguments"]
}
},
"require-dev": {
"ext-pdo_sqlite": "*",
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<testsuites>
<testsuite name="default">
<directory>tests/</directory>
<exclude>tests/named-arguments/</exclude>
</testsuite>
</testsuites>
<logging />
Expand Down
5 changes: 5 additions & 0 deletions tests/named-arguments/ExampleClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class ExampleClass
{
}
75 changes: 75 additions & 0 deletions tests/named-arguments/FlightTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Tests\PHP8;

use ExampleClass;
use Flight;
use flight\Engine;
use flight\net\Route;
use PHPUnit\Framework\TestCase;

class FlightTest extends TestCase
{
protected function setUp(): void
{
$_SERVER = [];
$_REQUEST = [];
Flight::init();
Flight::setEngine(new Engine());
}

protected function tearDown(): void
{
unset($_REQUEST);
unset($_SERVER);
Flight::clear();
}

//////////////////
// CORE METHODS //
//////////////////
public function test_path(): void
{
Flight::path(path: __DIR__);

$exampleObject = new ExampleClass();
self::assertInstanceOf(ExampleClass::class, $exampleObject);
}

public function test_stop_with_code(): void
{
Flight::stop(code: 500);

self::expectOutputString('');
self::assertSame(500, Flight::response()->status());
}

public function test_halt(): void
{
Flight::halt(500, actuallyExit: false, message: 'Test');

self::expectOutputString('Test');
self::assertSame(500, Flight::response()->status());
}

/////////////////////
// ROUTING METHODS //
/////////////////////
public function test_static_route(): void
{
Flight::request()->url = '/test';

$route = Flight::route(
pass_route: true,
alias: 'testRoute',
callback: function () {
echo 'test';
},
pattern: '/test'
);

self::assertInstanceOf(Route::class, $route);
self::expectOutputString('test');
Flight::start();
}
}