diff --git a/tests/server-v2/index.php b/tests/server-v2/index.php
index 1ebdd13..3eb765f 100644
--- a/tests/server-v2/index.php
+++ b/tests/server-v2/index.php
@@ -20,6 +20,9 @@ Flight::set('flight.v2.output_buffering', true);
// Test 1: Root route
Flight::route('/', function () {
echo 'Route text: Root route works!';
+ if (Flight::request()->query->redirected) {
+ echo '
Redirected from /redirect route successfully!';
+ }
});
Flight::route('/querytestpath', function () {
echo 'Route text: This ir query route
';
@@ -93,9 +96,32 @@ Flight::route('/protected', function () {
Flight::route('/template/@name', function ($name) {
Flight::render('template.phtml', ['name' => $name]);
});
+
+// Test 8: Throw an error
+Flight::route('/error', function () {
+ trigger_error('This is a successful error');
+});
+
+// Test 9: JSON output (should not output any other html)
+Flight::route('/json', function () {
+ echo "\n\n\n\n\n";
+ Flight::json(['message' => 'JSON renders successfully!']);
+ echo "\n\n\n\n\n";
+});
+
+// Test 10: Halt
+Flight::route('/halt', function () {
+ Flight::halt(400, 'Halt worked successfully');
+});
+
+// Test 11: Redirect
+Flight::route('/redirect', function () {
+ Flight::redirect('/?redirected=1');
+});
+
Flight::set('flight.views.path', './');
Flight::map('error', function (Throwable $error) {
- echo "
'; echo str_replace(getenv('PWD'), "***CLASSIFIED*****", $error->getTraceAsString()); echo ""; @@ -164,6 +190,10 @@ echo '
"; + echo 'Route text: This is query route
'; + echo "Query parameters:"; print_r(Flight::request()->query); echo ""; }, false, "querytestpath"); @@ -103,19 +103,18 @@ Flight::group('', function () { Flight::route('/halt', function () { Flight::halt(400, 'Halt worked successfully'); }); + + // Test 11: Redirect + Flight::route('/redirect', function () { + Flight::redirect('/?redirected=1'); + }); }, [ new LayoutMiddleware() ]); -// Test 9: JSON output +// Test 9: JSON output (should not output any other html) Flight::route('/json', function () { Flight::json(['message' => 'JSON renders successfully!']); }); - -// Test 11: Redirect -Flight::route('/redirect', function () { - Flight::redirect('/?redirected=1'); -}); - Flight::map('error', function (Throwable $e) { echo sprintf( '500 Internal Server Error
' .