Skip to content

Commit

Permalink
Tests: cover integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Jul 12, 2023
1 parent b233e4d commit d376611
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions tests/Cases/DI/SentryExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,27 @@ Toolkit::test(function (): void {
}, LogicalException::class, 'Missing Sentry DSN config');
});

// No integrations
// Default integrations
Toolkit::test(function (): void {
$container = ContainerBuilder::of()
->withCompiler(function (Compiler $compiler): void {
$compiler->addExtension('tracy', new TracyExtension());
$compiler->addExtension('sentry', new SentryExtension());
$compiler->addConfig(Neonkit::load('
sentry:
enable: true
client:
dsn: "https://[email protected]/12345678"
'));
})
->build();

call_user_func([$container, 'initialize']);

Assert::count(13, SentrySdk::getCurrentHub()->getClient()->getOptions()->getIntegrations());
});

// No default integrations
Toolkit::test(function (): void {
$container = ContainerBuilder::of()
->withCompiler(function (Compiler $compiler): void {
Expand All @@ -78,11 +98,40 @@ Toolkit::test(function (): void {
client:
dsn: "https://[email protected]/12345678"
integrations:
- Contributte\Sentry\Integration\ExtraIntegration([
version: 1.2.3
])
'));
})
->build();

call_user_func([$container, 'initialize']);

Assert::count(1, SentrySdk::getCurrentHub()->getClient()->getOptions()->getIntegrations());
});

// Merge integrations
Toolkit::test(function (): void {
$container = ContainerBuilder::of()
->withCompiler(function (Compiler $compiler): void {
$compiler->addExtension('tracy', new TracyExtension());
$compiler->addExtension('sentry', new SentryExtension());
$compiler->addConfig(Neonkit::load('
sentry:
enable: true
client:
dsn: "https://[email protected]/12345678"
integrations:
- Contributte\Sentry\Integration\ExtraIntegration([
version: 1.2.3
])
'));
})
->build();

call_user_func([$container, 'initialize']);

Assert::count(0, SentrySdk::getCurrentHub()->getClient()->getOptions()->getIntegrations());
Assert::count(14, SentrySdk::getCurrentHub()->getClient()->getOptions()->getIntegrations());
});

0 comments on commit d376611

Please sign in to comment.