File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 3
3
namespace NotificationChannels \Pushbullet \Test ;
4
4
5
5
use PHPUnit \Framework \TestCase ;
6
+ use PHPUnit \Framework \MockObject \MockObject ;
6
7
use NotificationChannels \Pushbullet \PushbulletMessage ;
8
+ use NotificationChannels \Pushbullet \Targets \Targetable ;
7
9
8
10
class PushbulletMessageTest extends TestCase
9
11
{
@@ -74,4 +76,30 @@ public function message_can_have_url_set()
74
76
75
77
$ this ->assertEquals ('http://example.com ' , $ message ->url );
76
78
}
79
+
80
+ /** @test */
81
+ public function it_can_be_cast_to_array ()
82
+ {
83
+ $ message = new PushbulletMessage ('Message ' );
84
+
85
+ /** @var MockObject|Targetable $target */
86
+ $ target = $ this ->createMock (Targetable::class);
87
+ $ target ->expects ($ this ->once ())
88
+ ->method ('getTarget ' )
89
+ ->willReturn (['tag ' => 'xcv ' ]);
90
+
91
+ $ message
92
+ ->title ('Hello ' )
93
+ ->target ($ target );
94
+
95
+ $ this ->assertEquals (
96
+ [
97
+ 'type ' => 'note ' ,
98
+ 'title ' => 'Hello ' ,
99
+ 'body ' => 'Message ' ,
100
+ 'tag ' => 'xcv ' ,
101
+ ],
102
+ $ message ->toArray ()
103
+ );
104
+ }
77
105
}
You can’t perform that action at this time.
0 commit comments