Skip to content

Commit 01e102d

Browse files
committed
test: added new test
1 parent ab8e311 commit 01e102d

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace NotificationChannels\Pushbullet\Test\Exceptions;
6+
7+
use NotificationChannels\Pushbullet\Exceptions\CouldNotSendNotification;
8+
use PHPUnit\Framework\TestCase;
9+
use Psr\Http\Message\ResponseInterface;
10+
11+
class CouldNotSendNotificationTest extends TestCase
12+
{
13+
/** @test */
14+
public function invalid_email_exception_can_be_created(): void
15+
{
16+
$exception = CouldNotSendNotification::providedEmailIsInvalid('[email protected]');
17+
18+
$this->assertEquals(
19+
'Provided email `[email protected]` of `notifiable` is not valid.',
20+
$exception->getMessage()
21+
);
22+
}
23+
24+
/** @test */
25+
public function pushbullet_connection_exception_can_be_created(): void
26+
{
27+
$exception = CouldNotSendNotification::couldNotCommunicateWithPushbullet();
28+
29+
$this->assertEquals(
30+
'Could not connect to Pushbullet API.',
31+
$exception->getMessage()
32+
);
33+
}
34+
35+
/** @test */
36+
public function pushbullet_error_exception_can_be_created(): void
37+
{
38+
$response = $this->createMock(ResponseInterface::class);
39+
40+
$response
41+
->method('getStatusCode')
42+
->willReturn(400);
43+
44+
$response
45+
->method('getBody')
46+
->willReturn('Oops');
47+
48+
$exception = CouldNotSendNotification::pushbulletRespondedWithAnError($response);
49+
50+
$this->assertEquals(
51+
'Pushbullet responded with error: `400 - Oops`.',
52+
$exception->getMessage()
53+
);
54+
}
55+
}

0 commit comments

Comments
 (0)