From 501176e2251a51ad7ee98cf4d6a7c3289e416434 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Sun, 25 Feb 2024 15:02:40 +0100 Subject: [PATCH] Fix workerman tests --- tests/Servers/Workerman.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/Servers/Workerman.php b/tests/Servers/Workerman.php index 5284d36..2d3be94 100644 --- a/tests/Servers/Workerman.php +++ b/tests/Servers/Workerman.php @@ -57,10 +57,10 @@ function cookies(Request $request): string { if ($request->get() === []) { - return new Response(body: json_encode($request->cookie())); + return encode($request->cookie()); } - $response = new Response(); + $response = new Response(headers: ['Content-Type' => 'application/json']); if ($set = $request->get('set')) { foreach ($set as $name => $value) { $response->cookie($name, $value); @@ -73,10 +73,12 @@ function cookies(Request $request): string foreach ($delete as $name) { if ($request->cookie($name)) { //unset($_COOKIE[$name]); + $cookies = $request->cookie(); + unset($cookies[$name]); $response->cookie($name, '', -1); } } - return $response->withBody(json_encode($request->cookie())); + return $response->withBody(json_encode($cookies)); } }