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
);
@@ -281,6 +283,19 @@ public function testBeforeBreadcrumbWithInvalidServiceReference(): void
281
283
$ this ->getOptionsFrom ($ container )->getBeforeBreadcrumbCallback ();
282
284
}
283
285
286
+ public function testIntegrations (): void
287
+ {
288
+ $ container = $ this ->getContainer ([
289
+ 'options ' => [
290
+ 'integrations ' => ['@integration_mock ' ],
291
+ ],
292
+ ]);
293
+
294
+ $ integrations = $ this ->getOptionsFrom ($ container )->getIntegrations ();
295
+ $ this ->assertContainsOnlyInstancesOf (IntegrationMock::class, $ integrations );
296
+ $ this ->assertCount (1 , $ integrations );
297
+ }
298
+
284
299
private function getContainer (array $ configuration = []): Container
285
300
{
286
301
$ containerBuilder = new ContainerBuilder ();
@@ -291,11 +306,9 @@ private function getContainer(array $configuration = []): Container
291
306
}
292
307
$ containerBuilder ->setParameter ('kernel.environment ' , 'test ' );
293
308
294
- $ mockEventDispatcher = $ this
295
- ->createMock (EventDispatcherInterface::class);
309
+ $ mockEventDispatcher = $ this ->createMock (EventDispatcherInterface::class);
296
310
297
- $ mockRequestStack = $ this
298
- ->createMock (RequestStack::class);
311
+ $ mockRequestStack = $ this ->createMock (RequestStack::class);
299
312
300
313
$ containerBuilder ->set ('request_stack ' , $ mockRequestStack );
301
314
$ containerBuilder ->set ('event_dispatcher ' , $ mockEventDispatcher );
@@ -307,6 +320,9 @@ private function getContainer(array $configuration = []): Container
307
320
$ beforeSend ->setFactory ([CallbackMock::class, 'createCallback ' ]);
308
321
$ containerBuilder ->setDefinition ('callable_mock ' , $ beforeSend );
309
322
323
+ $ integration = new Definition (IntegrationMock::class);
324
+ $ containerBuilder ->setDefinition ('integration_mock ' , $ integration );
325
+
310
326
$ extension = new SentryExtension ();
311
327
$ extension ->load (['sentry ' => $ configuration ], $ containerBuilder );
312
328
@@ -348,3 +364,10 @@ public static function createCallback(): callable
348
364
return [new self (), 'callback ' ];
349
365
}
350
366
}
367
+
368
+ class IntegrationMock implements IntegrationInterface
369
+ {
370
+ public function setupOnce (): void
371
+ {
372
+ }
373
+ }
0 commit comments