5
5
use PHPUnit \Framework \TestCase ;
6
6
use Sentry \Breadcrumb ;
7
7
use Sentry \Event ;
8
+ use Sentry \Integration \IntegrationInterface ;
8
9
use Sentry \Options ;
9
10
use Sentry \SentryBundle \DependencyInjection \SentryExtension ;
10
11
use Sentry \SentryBundle \EventListener \ConsoleListener ;
@@ -28,8 +29,9 @@ public function testDataProviderIsMappingTheRightNumberOfOptions(): void
28
29
$ providerData = $ this ->optionsValueProvider ();
29
30
$ supportedOptions = \array_unique (\array_column ($ providerData , 0 ));
30
31
32
+ // subtracted one is `integration`, which cannot be tested with the provider
31
33
$ this ->assertCount (
32
- ConfigurationTest::SUPPORTED_SENTRY_OPTIONS_COUNT ,
34
+ ConfigurationTest::SUPPORTED_SENTRY_OPTIONS_COUNT - 1 ,
33
35
$ supportedOptions ,
34
36
'Provider for configuration options mismatch: ' . PHP_EOL . print_r ($ supportedOptions , true )
35
37
);
@@ -280,6 +282,19 @@ public function testBeforeBreadcrumbWithInvalidServiceReference(): void
280
282
$ this ->getOptionsFrom ($ container )->getBeforeBreadcrumbCallback ();
281
283
}
282
284
285
+ public function testIntegrations (): void
286
+ {
287
+ $ container = $ this ->getContainer ([
288
+ 'options ' => [
289
+ 'integrations ' => ['@integration_mock ' ],
290
+ ],
291
+ ]);
292
+
293
+ $ integrations = $ this ->getOptionsFrom ($ container )->getIntegrations ();
294
+ $ this ->assertContainsOnlyInstancesOf (IntegrationMock::class, $ integrations );
295
+ $ this ->assertCount (1 , $ integrations );
296
+ }
297
+
283
298
private function getContainer (array $ configuration = []): Container
284
299
{
285
300
$ containerBuilder = new ContainerBuilder ();
@@ -290,11 +305,9 @@ private function getContainer(array $configuration = []): Container
290
305
}
291
306
$ containerBuilder ->setParameter ('kernel.environment ' , 'test ' );
292
307
293
- $ mockEventDispatcher = $ this
294
- ->createMock (EventDispatcherInterface::class);
308
+ $ mockEventDispatcher = $ this ->createMock (EventDispatcherInterface::class);
295
309
296
- $ mockRequestStack = $ this
297
- ->createMock (RequestStack::class);
310
+ $ mockRequestStack = $ this ->createMock (RequestStack::class);
298
311
299
312
$ containerBuilder ->set ('request_stack ' , $ mockRequestStack );
300
313
$ containerBuilder ->set ('event_dispatcher ' , $ mockEventDispatcher );
@@ -306,6 +319,9 @@ private function getContainer(array $configuration = []): Container
306
319
$ beforeSend ->setFactory ([CallbackMock::class, 'createCallback ' ]);
307
320
$ containerBuilder ->setDefinition ('callable_mock ' , $ beforeSend );
308
321
322
+ $ integration = new Definition (IntegrationMock::class);
323
+ $ containerBuilder ->setDefinition ('integration_mock ' , $ integration );
324
+
309
325
$ extension = new SentryExtension ();
310
326
$ extension ->load (['sentry ' => $ configuration ], $ containerBuilder );
311
327
@@ -347,3 +363,10 @@ public static function createCallback(): callable
347
363
return [new self (), 'callback ' ];
348
364
}
349
365
}
366
+
367
+ class IntegrationMock implements IntegrationInterface
368
+ {
369
+ public function setupOnce (): void
370
+ {
371
+ }
372
+ }
0 commit comments