Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix Hub bug introduced in #244 #253

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
</service>

<service id="Sentry\State\HubInterface" class="Sentry\State\Hub" public="false">
<argument type="service" id="Sentry\ClientInterface" />
<factory class="Sentry\SentryBundle\SentryBundle" method="getCurrentHub" />
<call method="bindClient">
<argument type="service" id="Sentry\ClientInterface" />
</call>
</service>

<service id="Sentry\SentryBundle\EventListener\ConsoleListener" class="Sentry\SentryBundle\EventListener\ConsoleListener" public="false">
Expand Down
7 changes: 7 additions & 0 deletions test/DependencyInjection/SentryExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Jean85\PrettyVersions;
use Monolog\Logger as MonologLogger;
use Prophecy\Argument;
use Sentry\Breadcrumb;
use Sentry\ClientInterface;
use Sentry\Event;
Expand All @@ -12,8 +13,10 @@
use Sentry\Options;
use Sentry\SentryBundle\DependencyInjection\SentryExtension;
use Sentry\SentryBundle\EventListener\ErrorListener;
use Sentry\SentryBundle\SentryBundle;
use Sentry\SentryBundle\Test\BaseTestCase;
use Sentry\Severity;
use Sentry\State\HubInterface;
use Sentry\State\Scope;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Container;
Expand Down Expand Up @@ -453,6 +456,10 @@ private function getContainer(array $configuration = []): Container
$containerBuilder->setAlias(self::MONOLOG_HANDLER_TEST_PUBLIC_ALIAS, new Alias(Handler::class, true));
}

$hub = $this->prophesize(HubInterface::class);
$hub->bindClient(Argument::type(ClientMock::class));
SentryBundle::setCurrentHub($hub->reveal());

$containerBuilder->compile();

return $containerBuilder;
Expand Down
4 changes: 4 additions & 0 deletions test/SentryBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Sentry\SentryBundle\EventListener\ErrorListener;
use Sentry\SentryBundle\EventListener\RequestListener;
use Sentry\SentryBundle\EventListener\SubRequestListener;
use Sentry\SentryBundle\SentryBundle;
use Sentry\State\Hub;
use Sentry\State\HubInterface;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -158,6 +160,8 @@ private function getContainer(array $configuration = []): ContainerBuilder
$extension = new SentryExtension();
$extension->load(['sentry' => $configuration], $containerBuilder);

SentryBundle::setCurrentHub(new Hub());

return $containerBuilder;
}
}