1 | <?php |
||||
2 | |||||
3 | namespace Tests\Feature\Notifications; |
||||
4 | |||||
5 | use Illuminate\Support\Facades\Notification; |
||||
6 | use Mockery; |
||||
7 | use Orchestra\Testbench\TestCase; |
||||
8 | use Exception; |
||||
9 | use Orchestra\Testbench\Exceptions\Handler; |
||||
10 | use Illuminate\Contracts\Debug\ExceptionHandler; |
||||
11 | use Skater4\LaravelSentryNotifications\Exceptions\SentryNotifierException; |
||||
12 | use Skater4\LaravelSentryNotifications\Notifications\Services\Telegram\Entities\NotifableTelegramChannel; |
||||
13 | use Skater4\LaravelSentryNotifications\Notifications\Services\Telegram\TelegramSentryNotification; |
||||
14 | use Skater4\LaravelSentryNotifications\Services\SentryNotifier; |
||||
15 | |||||
16 | class NotificationFlowTest extends TestCase |
||||
17 | { |
||||
18 | /** |
||||
19 | * @return void |
||||
20 | */ |
||||
21 | protected function setUp(): void |
||||
22 | { |
||||
23 | parent::setUp(); |
||||
24 | Notification::fake(); |
||||
25 | $this->app->instance(ExceptionHandler::class, new Handler(app())); |
||||
26 | } |
||||
27 | |||||
28 | /** |
||||
29 | * @return void |
||||
30 | * @throws SentryNotifierException |
||||
31 | */ |
||||
32 | public function testDirectCallOfReportSentryNotificationTriggersNotificationFlow() |
||||
33 | { |
||||
34 | $sentryNotifierMock = $this->mock(SentryNotifier::class); |
||||
35 | |||||
36 | $sentryNotifierMock->shouldReceive('reportSentryNotification') |
||||
37 | ->once() |
||||
38 | ->with(Mockery::type(Exception::class)) |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
39 | ->andReturnUsing(function () { |
||||
0 ignored issues
–
show
The method
andReturnUsing() does not exist on Mockery\ExpectationInterface . Did you maybe mean andReturn() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
40 | Notification::send(new NotifableTelegramChannel(123), new TelegramSentryNotification()); |
||||
41 | }); |
||||
42 | |||||
43 | /** @var SentryNotifier $sentryNotifierMock */ |
||||
44 | $sentryNotifierMock->reportSentryNotification(new Exception('Test exception')); |
||||
45 | |||||
46 | Notification::assertSentTo( |
||||
47 | new NotifableTelegramChannel(123), |
||||
48 | TelegramSentryNotification::class |
||||
49 | ); |
||||
50 | } |
||||
51 | } |
||||
52 |