testExceptionIsReportedToSentry()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.9666
eloc 9
cc 3
nc 1
nop 0
1
<?php
2
3
namespace Tests\Feature\Sentry;
4
5
use Orchestra\Testbench\TestCase;
6
use Exception;
7
use Skater4\LaravelSentryNotifications\Services\Sentry\SentryService;
8
9
class SentryIntegrationTest extends TestCase
10
{
11
    public function testExceptionIsReportedToSentry()
12
    {
13
        $this->mock(SentryService::class, function ($mock) {
14
            $mock->shouldReceive('captureException')
15
                ->once()
16
                ->withArgs(function ($exception) {
17
                    return $exception instanceof Exception && $exception->getMessage() === 'Test exception';
18
                });
19
        });
20
21
        try {
22
            throw new Exception('Test exception');
23
        } catch (Exception $e) {
24
            app(SentryService::class)->captureException($e);
25
        }
26
    }
27
}
28