File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 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 ('test@example.com ' );
17+
18+ $ this ->assertEquals (
19+ 'Provided email `test@example.com` 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+ }
You can’t perform that action at this time.
0 commit comments