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([]);