testTelegramNotificationDataStructure()   A
last analyzed

Complexity

Conditions 1
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 1
nc 1
nop 0
1
<?php
2
3
namespace Tests\Unit\Notifications\Services\Telegram;
4
5
use Orchestra\Testbench\TestCase;
6
use Skater4\LaravelSentryNotifications\Notifications\Services\Telegram\Entities\NotifableTelegramChannel;
7
use Skater4\LaravelSentryNotifications\Notifications\Services\Telegram\TelegramSentryNotification;
8
9
class TelegramSentryNotificationTest extends TestCase
10
{
11
    /**
12
     * @return void
13
     */
14
    public function testTelegramNotificationDataStructure()
15
    {
16
        $notification = new TelegramSentryNotification();
17
18
        $notifiable = $this->createMock(NotifableTelegramChannel::class);
19
        $notifiable->method('getChatId')->willReturn('123456789');
20
        $notifiable->method('getMessage')->willReturn('Error: wtf?');
21
22
        $data = $notification->toTelegram($notifiable);
23
24
        $this->assertNotNull($data->getPayloadValue('text'));
25
        $this->assertNotNull($data->getPayloadValue('chat_id'));
26
        $this->assertEquals('123456789', $data->getPayloadValue('chat_id'));
27
        $this->assertStringContainsString('Error', $data->getPayloadValue('text'));
0 ignored issues
show
Bug introduced by
It seems like $data->getPayloadValue('text') can also be of type null; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        $this->assertStringContainsString('Error', /** @scrutinizer ignore-type */ $data->getPayloadValue('text'));
Loading history...
28
    }
29
}
30