-
Notifications
You must be signed in to change notification settings - Fork 418
Expand file tree
/
Copy pathFlightAsyncTest.php
More file actions
83 lines (67 loc) · 1.75 KB
/
FlightAsyncTest.php
File metadata and controls
83 lines (67 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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(): void
{
Flight::route('GET /', function () {
echo 'hello world';
});
$this->expectOutputString('hello world');
Flight::start();
}
public function testMultipleRoutes(): void
{
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(): void
{
Flight::route('GET /', function () {
echo 'hello world';
});
$this->expectOutputString('hello worldhello world');
Flight::start();
Flight::start();
}
public function testMultipleStartsMultipleRoutes(): void
{
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();
}
}