Skip to content

Commit f6001e4

Browse files
committed
skip tests if config option doesn't exist
1 parent 124c973 commit f6001e4

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

tests/Command/BreadcrumbTestCommandTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Command;
66

77
use Monolog\Handler\BufferHandler;
8-
use Monolog\Level;
98
use Monolog\Logger;
109
use PHPUnit\Framework\TestCase;
1110
use Psr\Log\LoggerInterface;
@@ -20,7 +19,6 @@
2019
use Sentry\SentryBundle\EventListener\ConsoleListener;
2120
use Sentry\SentryBundle\Tests\End2End\StubTransport;
2221
use Sentry\State\Hub;
23-
use Sentry\State\HubInterface;
2422
use Symfony\Component\Console\Application;
2523
use Symfony\Component\Console\ConsoleEvents;
2624
use Symfony\Component\Console\Input\ArgvInput;
@@ -34,11 +32,6 @@
3432
*/
3533
class BreadcrumbTestCommandTest extends TestCase
3634
{
37-
/**
38-
* @var HubInterface
39-
*/
40-
private $hub;
41-
4235
/**
4336
* @var LoggerInterface
4437
*/
@@ -73,7 +66,6 @@ protected function setUp(): void
7366
$bufferHandler = new BufferHandler($handler);
7467
$dispatcher->addSubscriber(new BufferFlusher([$bufferHandler]));
7568

76-
$this->hub = $hub;
7769
$this->logger = new Logger('test', [$bufferHandler, $breadcrumbHandler]);
7870
}
7971

tests/End2End/BufferFlushEnd2EndTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Bundle\FrameworkBundle\Client;
99
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1010
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
11+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1112

1213
if (!class_exists(KernelBrowser::class) && class_exists(Client::class)) {
1314
class_alias(Client::class, KernelBrowser::class);
@@ -18,7 +19,6 @@ class_alias(Client::class, KernelBrowser::class);
1819
*/
1920
class BufferFlushEnd2EndTest extends WebTestCase
2021
{
21-
2222
protected function setUp(): void
2323
{
2424
StubTransport::$events = [];
@@ -34,7 +34,14 @@ protected static function getKernelClass(): string
3434
*/
3535
public function testLogMessagesBufferedAndFlushedAfterKernelTermination(): void
3636
{
37-
$client = static::createClient(['debug' => false]);
37+
try {
38+
$client = static::createClient(['debug' => false]);
39+
} catch (InvalidConfigurationException $e) {
40+
if (str_starts_with($e->getMessage(), 'Unrecognized option "hub_id" under "monolog.handlers.sentry"')) {
41+
$this->markTestSkipped('Skipped because "hub_id" option does not exist for this PHP/Symfony version');
42+
}
43+
$this->fail();
44+
}
3845

3946
$client->request('GET', '/buffer-flush');
4047

0 commit comments

Comments
 (0)