From fcf208331b182200331637eef98a6700528b9d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Tue, 25 Aug 2026 03:00:47 +0200 Subject: [PATCH] Cover API response fallbacks --- tests/Unit/API/APIResponseTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Unit/API/APIResponseTest.php b/tests/Unit/API/APIResponseTest.php index 0475852..72dfad6 100644 --- a/tests/Unit/API/APIResponseTest.php +++ b/tests/Unit/API/APIResponseTest.php @@ -69,6 +69,19 @@ public function testHeadersArrayPreservesRepeatedValues(): void ); } + public function testHeadersArrayIgnoresInvalidProtocolEntries(): void + { + $response = new APIResponse([ + 'headersArray' => [ + 'invalid', + ['name' => 123, 'value' => 'value'], + ['name' => 'x-valid', 'value' => 'value'], + ], + ]); + + $this->assertSame(['x-valid' => ['value']], $response->headersArray()); + } + public function testHeadersArrayFallsBackToNormalizedHeaders(): void { $response = new APIResponse([ @@ -105,6 +118,13 @@ public function testInvalidBase64RaisesAPlaywrightException(): void $response->text(); } + public function testNonStringBodyUsesAnEmptyString(): void + { + $response = new APIResponse(['body' => ['not', 'a', 'string']]); + + $this->assertSame('', $response->text()); + } + public function testMissingValuesUseSafeDefaults(): void { $response = new APIResponse([]);