Skip to content

Commit 2dd1969

Browse files
committed
Add integration test for the ClientBuilder configurator
1 parent f5c0858 commit 2dd1969

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/DependencyInjection/ClientBuilderConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function configure(ClientBuilderInterface $clientBuilder): void
2121
}
2222

2323
$integrations = $options->getIntegrations();
24-
$options->setIntegrations(array_filter($integrations, function (IntegrationInterface $integration) {
24+
$options->setIntegrations(array_filter($integrations, static function (IntegrationInterface $integration): bool {
2525
if ($integration instanceof ErrorListenerIntegration) {
2626
return false;
2727
}

test/SentryBundleTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
namespace Sentry\SentryBundle\Test;
44

55
use PHPUnit\Framework\TestCase;
6+
use Sentry\Integration\ErrorListenerIntegration;
7+
use Sentry\Integration\ExceptionListenerIntegration;
8+
use Sentry\Integration\IntegrationInterface;
9+
use Sentry\Integration\RequestIntegration;
610
use Sentry\SentryBundle\DependencyInjection\SentryExtension;
711
use Sentry\SentryBundle\EventListener\ConsoleListener;
812
use Sentry\SentryBundle\EventListener\ErrorListener;
913
use Sentry\SentryBundle\EventListener\RequestListener;
1014
use Sentry\SentryBundle\EventListener\SubRequestListener;
15+
use Sentry\State\HubInterface;
1116
use Symfony\Component\Console\ConsoleEvents;
1217
use Symfony\Component\DependencyInjection\ContainerBuilder;
1318
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -116,10 +121,23 @@ public function testContainerHasErrorListenerConfiguredCorrectly(): void
116121
$this->assertSame($expectedTag, $consoleListener->getTags());
117122
}
118123

124+
public function testIntegrationsListenersAreDisabledByDefault(): void
125+
{
126+
$container = $this->getContainer();
127+
128+
$hub = $container->get(HubInterface::class);
129+
130+
$this->assertInstanceOf(HubInterface::class, $hub);
131+
$this->assertInstanceOf(IntegrationInterface::class, $hub->getIntegration(RequestIntegration::class));
132+
$this->assertNull($hub->getIntegration(ErrorListenerIntegration::class));
133+
$this->assertNull($hub->getIntegration(ExceptionListenerIntegration::class));
134+
}
135+
119136
private function getContainer(array $configuration = []): ContainerBuilder
120137
{
121138
$containerBuilder = new ContainerBuilder();
122139
$containerBuilder->setParameter('kernel.root_dir', 'kernel/root');
140+
$containerBuilder->setParameter('kernel.cache_dir', 'var/cache');
123141
if (method_exists(Kernel::class, 'getProjectDir')) {
124142
$containerBuilder->setParameter('kernel.project_dir', '/dir/project/root');
125143
}

0 commit comments

Comments
 (0)