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 33namespace NotificationChannels \Pushbullet \Test ;
44
55use PHPUnit \Framework \TestCase ;
6+ use PHPUnit \Framework \MockObject \MockObject ;
67use NotificationChannels \Pushbullet \PushbulletMessage ;
8+ use NotificationChannels \Pushbullet \Targets \Targetable ;
79
810class PushbulletMessageTest extends TestCase
911{
@@ -74,4 +76,30 @@ public function message_can_have_url_set()
7476
7577 $ this ->assertEquals ('http://example.com ' , $ message ->url );
7678 }
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+ }
77105}
You can’t perform that action at this time.
0 commit comments