Skip to content

Commit 3c978ac

Browse files
committed
Fix tests
1 parent 73829ee commit 3c978ac

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

tests/Tracing/HttpClient/TraceableHttpClientTest.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Sentry\Tracing\TraceId;
2323
use Sentry\Tracing\Transaction;
2424
use Sentry\Tracing\TransactionContext;
25+
use Symfony\Component\HttpClient\HttpClient;
2526
use Symfony\Component\HttpClient\MockHttpClient;
2627
use Symfony\Component\HttpClient\Response\MockResponse;
2728
use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -46,7 +47,7 @@ final class TraceableHttpClientTest extends TestCase
4647

4748
public static function setUpBeforeClass(): void
4849
{
49-
if (!self::isHttpClientPackageInstalled()) {
50+
if (!class_exists(HttpClient::class)) {
5051
self::markTestSkipped('This test requires the "symfony/http-client" Composer package to be installed.');
5152
}
5253
}
@@ -357,13 +358,10 @@ public function testWithOptions(): void
357358
$this->assertSame('GET', $response->getInfo('http_method'));
358359
$this->assertSame('https://www.example.org/test-page', $response->getInfo('url'));
359360
}
361+
}
360362

361-
private static function isHttpClientPackageInstalled(): bool
363+
if (interface_exists(HttpClientInterface::class)) {
364+
interface TestableHttpClientInterface extends HttpClientInterface, LoggerAwareInterface, ResetInterface
362365
{
363-
return interface_exists(HttpClientInterface::class);
364366
}
365367
}
366-
367-
interface TestableHttpClientInterface extends HttpClientInterface, LoggerAwareInterface, ResetInterface
368-
{
369-
}

tests/Tracing/HttpClient/TraceableResponseTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Sentry\Tracing\SpanContext;
1313
use Sentry\Tracing\Transaction;
1414
use Sentry\Tracing\TransactionContext;
15+
use Symfony\Component\HttpClient\HttpClient;
1516
use Symfony\Component\HttpClient\MockHttpClient;
1617
use Symfony\Component\HttpClient\Response\MockResponse;
1718
use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -28,6 +29,13 @@ final class TraceableResponseTest extends TestCase
2829
*/
2930
private $hub;
3031

32+
public static function setUpBeforeClass(): void
33+
{
34+
if (!class_exists(HttpClient::class)) {
35+
self::markTestSkipped('This test requires the "symfony/http-client" Composer package to be installed.');
36+
}
37+
}
38+
3139
protected function setUp(): void
3240
{
3341
$this->client = $this->createMock(HttpClientInterface::class);

0 commit comments

Comments
 (0)