-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IgnoreErrorIntegration: ignore Event message
- Loading branch information
Showing
7 changed files
with
220 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
tests/Cases/Integration/IgnoreErrorIntegration/FailedIgnore.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use Contributte\Sentry\Integration\IgnoreErrorIntegration; | ||
use Ninjify\Nunjuck\Toolkit; | ||
use Sentry\ClientInterface; | ||
use Sentry\Event; | ||
use Sentry\ExceptionDataBag; | ||
use Sentry\SentrySdk; | ||
use Sentry\State\Scope; | ||
use Tester\Assert; | ||
use function Sentry\withScope; | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
// not matched exception and event | ||
Toolkit::test(function (): void { | ||
$integration = new IgnoreErrorIntegration([ | ||
'ignore_exception_regex' => [ | ||
'#foo bar#', | ||
], | ||
'ignore_message_regex' => [ | ||
'#foo bar#', | ||
], | ||
]); | ||
$integration->setupOnce(); | ||
|
||
$client = Mockery::mock(ClientInterface::class); | ||
$client->shouldReceive('getIntegration') | ||
->once() | ||
->andReturn($integration); | ||
|
||
SentrySdk::getCurrentHub()->bindClient($client); | ||
|
||
$event = Event::createEvent(); | ||
$event->setExceptions([new ExceptionDataBag(new RuntimeException('bar foo'))]); | ||
$event->setMessage('bar foo'); | ||
|
||
withScope(function (Scope $scope) use ($event): void { | ||
$newEvent = $scope->applyToEvent($event); | ||
Assert::equal($event, $newEvent); | ||
}); | ||
}); | ||
|
||
// not matched exception and no event message | ||
Toolkit::test(function (): void { | ||
$integration = new IgnoreErrorIntegration([ | ||
'ignore_exception_regex' => [ | ||
'#foo bar#', | ||
], | ||
'ignore_message_regex' => [ | ||
'#foo bar#', | ||
], | ||
]); | ||
$integration->setupOnce(); | ||
|
||
$client = Mockery::mock(ClientInterface::class); | ||
$client->shouldReceive('getIntegration') | ||
->once() | ||
->andReturn($integration); | ||
|
||
SentrySdk::getCurrentHub()->bindClient($client); | ||
|
||
$event = Event::createEvent(); | ||
$event->setExceptions([new ExceptionDataBag(new RuntimeException('bar foo'))]); | ||
|
||
withScope(function (Scope $scope) use ($event): void { | ||
$newEvent = $scope->applyToEvent($event); | ||
Assert::equal($event, $newEvent); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/Cases/Integration/IgnoreErrorIntegration/IgnoreExceptionAndMessage.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use Contributte\Sentry\Integration\IgnoreErrorIntegration; | ||
use Ninjify\Nunjuck\Toolkit; | ||
use Sentry\ClientInterface; | ||
use Sentry\Event; | ||
use Sentry\ExceptionDataBag; | ||
use Sentry\SentrySdk; | ||
use Sentry\State\Scope; | ||
use Tester\Assert; | ||
use function Sentry\withScope; | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
// Ignore exception and message | ||
Toolkit::test(function (): void { | ||
$integration = new IgnoreErrorIntegration([ | ||
'ignore_exception_regex' => [ | ||
'#bar foo#', | ||
], | ||
'ignore_message_regex' => [ | ||
'#foo bar#', | ||
], | ||
]); | ||
$integration->setupOnce(); | ||
|
||
$client = Mockery::mock(ClientInterface::class); | ||
$client->shouldReceive('getIntegration') | ||
->once() | ||
->andReturn($integration); | ||
|
||
SentrySdk::getCurrentHub()->bindClient($client); | ||
|
||
$event = Event::createEvent(); | ||
$event->setMessage('foo bar'); | ||
$event->setExceptions([new ExceptionDataBag(new RuntimeException('bar foo'))]); | ||
|
||
withScope(function (Scope $scope) use ($event): void { | ||
$event = $scope->applyToEvent($event); | ||
Assert::null($event); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
tests/Cases/Integration/IgnoreErrorIntegration/IgnoreMessage.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use Contributte\Sentry\Integration\IgnoreErrorIntegration; | ||
use Ninjify\Nunjuck\Toolkit; | ||
use Sentry\ClientInterface; | ||
use Sentry\Event; | ||
use Sentry\SentrySdk; | ||
use Sentry\State\Scope; | ||
use Tester\Assert; | ||
use function Sentry\withScope; | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
// Ignore message | ||
Toolkit::test(function (): void { | ||
$integration = new IgnoreErrorIntegration([ | ||
'ignore_message_regex' => [ | ||
'#foo bar#', | ||
], | ||
]); | ||
$integration->setupOnce(); | ||
|
||
$client = Mockery::mock(ClientInterface::class); | ||
$client->shouldReceive('getIntegration') | ||
->once() | ||
->andReturn($integration); | ||
|
||
SentrySdk::getCurrentHub()->bindClient($client); | ||
|
||
$event = Event::createEvent(); | ||
$event->setMessage('foo bar'); | ||
|
||
withScope(function (Scope $scope) use ($event): void { | ||
$event = $scope->applyToEvent($event); | ||
Assert::null($event); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
tests/Cases/Integration/IgnoreErrorIntegration/IgnoreMessageWithException.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use Contributte\Sentry\Integration\IgnoreErrorIntegration; | ||
use Ninjify\Nunjuck\Toolkit; | ||
use Sentry\ClientInterface; | ||
use Sentry\Event; | ||
use Sentry\ExceptionDataBag; | ||
use Sentry\SentrySdk; | ||
use Sentry\State\Scope; | ||
use Tester\Assert; | ||
use function Sentry\withScope; | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
// not matched exception and matched event | ||
Toolkit::test(function (): void { | ||
$integration = new IgnoreErrorIntegration([ | ||
'ignore_exception_regex' => [ | ||
'#foo bar#', | ||
], | ||
'ignore_message_regex' => [ | ||
'#foo bar#', | ||
], | ||
]); | ||
$integration->setupOnce(); | ||
|
||
$client = Mockery::mock(ClientInterface::class); | ||
$client->shouldReceive('getIntegration') | ||
->once() | ||
->andReturn($integration); | ||
|
||
SentrySdk::getCurrentHub()->bindClient($client); | ||
|
||
$event = Event::createEvent(); | ||
$event->setMessage('foo bar'); | ||
$event->setExceptions([new ExceptionDataBag(new RuntimeException('bar foo'))]); | ||
|
||
withScope(function (Scope $scope) use ($event): void { | ||
$event = $scope->applyToEvent($event); | ||
Assert::null($event); | ||
}); | ||
}); |