Skip to content

Commit

Permalink
fix: Support sentry 4.x
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Only supports sentry 4.6.1+
  • Loading branch information
Stephan Wentz committed Mar 8, 2024
1 parent 5b57d21 commit 1dafe75
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 35 deletions.
32 changes: 16 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
"require": {
"php": "^8.2",
"ext-iconv": "*",
"bgalati/monolog-sentry-handler": "^2.0",
"bgalati/monolog-sentry-handler": "^2.1",
"jean85/pretty-package-versions": "^2.0",
"monolog/monolog": "^3.0",
"nyholm/psr7": "^1.2.1",
"psr/log": "^1.1|^2.0|^3.0",
"sentry/sentry": "^3.1|^4.0",
"symfony/config": "^6.2|^7.0",
"symfony/dependency-injection": "^6.2|^7.0",
"symfony/http-client": "^6.2|^7.0",
"symfony/http-kernel": "^6.2|^7.0",
"symfony/yaml": "^6.2|^7.0"
"sentry/sentry": "^4.6.1",
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0"
},
"require-dev": {
"brainbits/phpcs-standard": "^7.0",
"ergebnis/phpstan-rules": "^2.0",
"nyholm/nsa": "^1.2",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^10.1",
"symfony/console": "^6.2|^7.0",
"symfony/messenger": "^6.2|^7.0",
"symfony/security-bundle": "^6.2|^7.0",
"brainbits/phpcs-standard": "^7.0.1",
"ergebnis/phpstan-rules": "^2.2",
"nyholm/nsa": "^1.3",
"phpstan/phpstan": "^1.10.59",
"phpstan/phpstan-phpunit": "^1.3.16",
"phpunit/phpunit": "^11.0.4",
"symfony/console": "^6.4|^7.0.4",
"symfony/messenger": "^6.4|^7.0.4",
"symfony/security-bundle": "^6.4|^7.0.4",
"thecodingmachine/phpstan-strict-rules": "^1.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuite name="sentry-bundle">
<directory>tests</directory>
Expand Down
2 changes: 1 addition & 1 deletion src/SentryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function create(
'in_app_exclude' => $inAppExclude ?? [],
'prefixes' => $prefixes ?? [],
'release' => $release,
'attach_stacktrace' => false,
'default_integrations' => false,
'send_attempts' => 1,
'integrations' => [
new RequestIntegration(),
new EnvironmentIntegration(),
Expand Down
3 changes: 2 additions & 1 deletion tests/EventListener/MonologResetterEventListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

use Brainbits\MonologSentry\EventListener\MonologResetterEventListener;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use stdClass;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;

/** @covers \Brainbits\MonologSentry\EventListener\MonologResetterEventListener */
#[CoversClass(MonologResetterEventListener::class)]
final class MonologResetterEventListenerTest extends TestCase
{
use HubExpections;
Expand Down
3 changes: 2 additions & 1 deletion tests/EventListener/SentryConsoleListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Brainbits\MonologSentry\EventListener\SentryConsoleListener;
use Exception;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject; // phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
Expand All @@ -18,7 +19,7 @@
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;

/** @covers \Brainbits\MonologSentry\EventListener\SentryConsoleListener */
#[CoversClass(SentryConsoleListener::class)]
final class SentryConsoleListenerTest extends TestCase
{
use HubExpections;
Expand Down
3 changes: 2 additions & 1 deletion tests/EventListener/SentryRequestListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Brainbits\MonologSentryTests\EventListener;

use Brainbits\MonologSentry\EventListener\SentryRequestListener;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject; // phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
Expand All @@ -17,7 +18,7 @@
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\KernelEvents;

/** @covers \Brainbits\MonologSentry\EventListener\SentryRequestListener */
#[CoversClass(SentryRequestListener::class)]
final class SentryRequestListenerTest extends TestCase
{
use HubExpections;
Expand Down
3 changes: 2 additions & 1 deletion tests/EventListener/SentryUserListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Brainbits\MonologSentryTests\EventListener;

use Brainbits\MonologSentry\EventListener\SentryUserListener;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject; // phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
use PHPUnit\Framework\TestCase;
use Sentry\State\HubInterface;
Expand All @@ -17,7 +18,7 @@
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\User\InMemoryUser;

/** @covers \Brainbits\MonologSentry\EventListener\SentryUserListener */
#[CoversClass(SentryUserListener::class)]
final class SentryUserListenerTest extends TestCase
{
use HubExpections;
Expand Down
18 changes: 5 additions & 13 deletions tests/SentryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
namespace Brainbits\MonologSentryTests;

use Brainbits\MonologSentry\SentryFactory;
use Http\Client\Common\PluginClient;
use Nyholm\NSA;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Sentry\Client;
use Sentry\Dsn;
use Sentry\HttpClient\HttpClient;
use Sentry\Options;
use Sentry\SentrySdk;
use Sentry\State\Layer;
use Sentry\Transport\HttpTransport;
use Sentry\Transport\NullTransport;
use Symfony\Component\HttpClient\HttplugClient;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function assert;
use function is_array;
Expand All @@ -27,7 +25,7 @@
use const PHP_SAPI;
use const PHP_VERSION;

/** @covers \Brainbits\MonologSentry\SentryFactory */
#[CoversClass(SentryFactory::class)]
final class SentryFactoryTest extends TestCase
{
public function testClientHasExpectedServices(): void
Expand Down Expand Up @@ -67,13 +65,7 @@ public function testClientHasExpectedServices(): void
self::assertSame(['_projectDir'], $options->getPrefixes());

$pluginClient = NSA::getProperty($transport, 'httpClient');
self::assertInstanceOf(PluginClient::class, $pluginClient);

$httplugClient = NSA::getProperty($pluginClient, 'client');
self::assertInstanceOf(HttplugClient::class, $httplugClient);

$httpClient = NSA::getProperty($httplugClient, 'client');
self::assertInstanceOf(HttpClientInterface::class, $httpClient);
self::assertInstanceOf(HttpClient::class, $pluginClient);

$hub = SentrySdk::getCurrentHub();
$stack = NSA::getProperty($hub, 'stack');
Expand Down Expand Up @@ -108,7 +100,7 @@ public function testMinimalParameters(): void
self::assertInstanceOf(Client::class, $client);

$transport = NSA::getProperty($client, 'transport');
self::assertInstanceOf(NullTransport::class, $transport);
self::assertInstanceOf(HttpTransport::class, $transport);

$options = $client->getOptions();
self::assertInstanceOf(Options::class, $options);
Expand Down

0 comments on commit 1dafe75

Please sign in to comment.