Skip to content

Commit ab4b8ce

Browse files
committed
Merge branch '1.0'
2 parents 5375492 + 539f7e9 commit ab4b8ce

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/PushbulletMessageTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace NotificationChannels\Pushbullet\Test;
44

55
use PHPUnit\Framework\TestCase;
6+
use PHPUnit\Framework\MockObject\MockObject;
67
use NotificationChannels\Pushbullet\PushbulletMessage;
8+
use NotificationChannels\Pushbullet\Targets\Targetable;
79

810
class 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
}

0 commit comments

Comments
 (0)