-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #622 from flightphp/new-request-object
Added ability to generate new requests/responses on duplicate start()
- Loading branch information
Showing
7 changed files
with
170 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace tests; | ||
|
||
use Flight; | ||
use flight\Engine; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FlightAsyncTest extends TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
Flight::setEngine(new Engine()); | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
$_SERVER = []; | ||
$_REQUEST = []; | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
unset($_REQUEST); | ||
unset($_SERVER); | ||
} | ||
|
||
// Checks that default components are loaded | ||
public function testSingleRoute() | ||
{ | ||
Flight::route('GET /', function () { | ||
echo 'hello world'; | ||
}); | ||
|
||
$this->expectOutputString('hello world'); | ||
Flight::start(); | ||
} | ||
|
||
public function testMultipleRoutes() | ||
{ | ||
Flight::route('GET /', function () { | ||
echo 'hello world'; | ||
}); | ||
|
||
Flight::route('GET /test', function () { | ||
echo 'test'; | ||
}); | ||
|
||
$this->expectOutputString('test'); | ||
$_SERVER['REQUEST_URI'] = '/test'; | ||
Flight::start(); | ||
} | ||
|
||
public function testMultipleStartsSingleRoute() | ||
{ | ||
Flight::route('GET /', function () { | ||
echo 'hello world'; | ||
}); | ||
|
||
$this->expectOutputString('hello worldhello world'); | ||
Flight::start(); | ||
Flight::start(); | ||
} | ||
|
||
public function testMultipleStartsMultipleRoutes() | ||
{ | ||
Flight::route('GET /', function () { | ||
echo 'hello world'; | ||
}); | ||
|
||
Flight::route('GET /test', function () { | ||
echo 'test'; | ||
}); | ||
|
||
$this->expectOutputString('testhello world'); | ||
$_SERVER['REQUEST_URI'] = '/test'; | ||
Flight::start(); | ||
$_SERVER['REQUEST_URI'] = '/'; | ||
Flight::start(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters