Passed
Branch master (f22fa7)
by Stan
04:08
created

SentryNotifierTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 23
rs 10
eloc 13

1 Method

Rating   Name   Duplication   Size   Complexity  
A testReportSentryNotification() 0 17 1
1
<?php
2
3
namespace Tests\Unit\Services;
4
5
use PHPUnit\Framework\TestCase;
6
use Skater4\LaravelSentryNotifications\Exceptions\SentryNotifierException;
7
use Skater4\LaravelSentryNotifications\Services\SentryNotifier;
8
use Skater4\LaravelSentryNotifications\Services\Messengers\Interfaces\MessengerClientInterface;
9
use Skater4\LaravelSentryNotifications\Services\Sentry\Interfaces\SentryServiceInterface;
10
use Exception;
11
12
class SentryNotifierTest extends TestCase
13
{
14
    /**
15
     * @return void
16
     * @throws SentryNotifierException
17
     */
18
    public function testReportSentryNotification()
19
    {
20
        $messengerClientMock = $this->createMock(MessengerClientInterface::class);
21
        $messengerClientMock->expects($this->once())
22
            ->method('sendMessage')
23
            ->with($this->isInstanceOf(Exception::class), $this->stringContains('http://example.com/event'));
24
25
        $sentryServiceMock = $this->createMock(SentryServiceInterface::class);
26
        $sentryServiceMock->method('captureException')
27
            ->willReturn('event_id');
28
        $sentryServiceMock->method('getIssueUrl')
29
            ->with('event_id')
30
            ->willReturn('http://example.com/event');
31
32
        $sentryNotifier = new SentryNotifier($messengerClientMock, $sentryServiceMock);
33
34
        $sentryNotifier->reportSentryNotification(new Exception('Test exception'));
35
    }
36
}
37