Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed May 24, 2024
1 parent f2915f8 commit ace23a8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/HttpClient/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,32 @@ public function testClientMakesUncompressedRequestWhenCompressionDisabled(): voi
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals($response->getStatusCode(), $serverOutput['status']);
$this->assertEquals($request->getStringBody(), $serverOutput['body']);
$this->assertEquals($response->getError(), '');
$this->assertEquals(\strlen($request->getStringBody()), $serverOutput['headers']['Content-Length']);
}

public function testClientReturnsBodyAsErrorOnNonSuccessStatusCode(): void
{
$testServer = $this->startTestServer();

$options = new Options([
'dsn' => "http://publicKey@{$testServer}/400",
]);

$request = new Request();
$request->setStringBody('test');

$client = new HttpClient('sentry.php', 'testing');
$response = $client->sendRequest($request, $options);

$this->stopTestServer();

$this->assertFalse($response->isSuccess());
$this->assertEquals(400, $response->getStatusCode());

$this->assertEquals($request->getStringBody(), $response->getError());
}

public function testThrowsExceptionIfDsnOptionIsNotSet(): void
{
$this->expectException(\RuntimeException::class);
Expand Down

0 comments on commit ace23a8

Please sign in to comment.