Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Apr 8, 2024
1 parent 73829ee commit 3c978ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/Tracing/HttpClient/TraceableHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Sentry\Tracing\TraceId;
use Sentry\Tracing\Transaction;
use Sentry\Tracing\TransactionContext;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand All @@ -46,7 +47,7 @@ final class TraceableHttpClientTest extends TestCase

public static function setUpBeforeClass(): void
{
if (!self::isHttpClientPackageInstalled()) {
if (!class_exists(HttpClient::class)) {
self::markTestSkipped('This test requires the "symfony/http-client" Composer package to be installed.');
}
}
Expand Down Expand Up @@ -357,13 +358,10 @@ public function testWithOptions(): void
$this->assertSame('GET', $response->getInfo('http_method'));
$this->assertSame('https://www.example.org/test-page', $response->getInfo('url'));
}
}

private static function isHttpClientPackageInstalled(): bool
if (interface_exists(HttpClientInterface::class)) {
interface TestableHttpClientInterface extends HttpClientInterface, LoggerAwareInterface, ResetInterface
{
return interface_exists(HttpClientInterface::class);
}
}

interface TestableHttpClientInterface extends HttpClientInterface, LoggerAwareInterface, ResetInterface
{
}
8 changes: 8 additions & 0 deletions tests/Tracing/HttpClient/TraceableResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Sentry\Tracing\SpanContext;
use Sentry\Tracing\Transaction;
use Sentry\Tracing\TransactionContext;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand All @@ -28,6 +29,13 @@ final class TraceableResponseTest extends TestCase
*/
private $hub;

public static function setUpBeforeClass(): void
{
if (!class_exists(HttpClient::class)) {
self::markTestSkipped('This test requires the "symfony/http-client" Composer package to be installed.');
}
}

protected function setUp(): void
{
$this->client = $this->createMock(HttpClientInterface::class);
Expand Down

0 comments on commit 3c978ac

Please sign in to comment.