-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCouldNotSendNotificationTest.php
More file actions
61 lines (48 loc) · 1.78 KB
/
Copy pathCouldNotSendNotificationTest.php
File metadata and controls
61 lines (48 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace NotificationChannels\Pushbullet\Test\Exceptions;
use Exception;
use NotificationChannels\Pushbullet\Exceptions\CouldNotSendNotification;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
class CouldNotSendNotificationTest extends TestCase
{
/** @test */
public function invalid_email_exception_can_be_created(): void
{
$exception = CouldNotSendNotification::providedEmailIsInvalid('test@example.com');
$this->assertEquals(
'Provided email `test@example.com` of `notifiable` is not valid.',
$exception->getMessage()
);
}
/** @test */
public function pushbullet_connection_exception_can_be_created(): void
{
$previousException = new Exception();
$exception = CouldNotSendNotification::couldNotCommunicateWithPushbullet($previousException);
$this->assertEquals(
'Could not connect to Pushbullet API.',
$exception->getMessage()
);
$this->assertSame($previousException, $exception->getPrevious());
}
/** @test */
public function pushbullet_error_exception_can_be_created(): void
{
$response = $this->createMock(ResponseInterface::class);
$response
->method('getStatusCode')
->willReturn(400);
$response
->method('getBody')
->willReturn('Oops');
$previousException = new Exception();
$exception = CouldNotSendNotification::pushbulletRespondedWithAnError($response, $previousException);
$this->assertEquals(
'Pushbullet responded with error: `400 - Oops`.',
$exception->getMessage()
);
$this->assertSame($previousException, $exception->getPrevious());
}
}