Add phpunit tests for header key/value exceptions

This commit is contained in:
Clemens Schwaighofer
2024-11-06 18:49:48 +09:00
parent f9cf36524e
commit 0c51a3be87

View File

@@ -1043,6 +1043,46 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
$curl->request('wrong', 'http://foo.bar.com');
}
/**
* Exception:InvalidHeaderKey
*
* @covers ::request
* @testdox UrlRequests\Curl Exception:InvalidHeaderKey
*
* @return void
*/
public function testExceptionInvalidHeaderKey(): void
{
$curl = new \CoreLibs\UrlRequests\Curl();
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/InvalidHeaderKey/");
$curl->request('get', $this->url_basic, [
"headers" => [
"(invalid-key)" => "key"
]
]);
}
/**
* Exception:InvalidHeaderValue
*
* @covers ::request
* @testdox UrlRequests\Curl Exception:InvalidHeaderValue
*
* @return void
*/
public function testExceptionInvalidHeaderValue(): void
{
$curl = new \CoreLibs\UrlRequests\Curl();
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/InvalidHeaderValue/");
$curl->request('get', $this->url_basic, [
"headers" => [
"invalid-value" => "\x19\x10"
]
]);
}
/**
* TODO: Exception:CurlInitError
*