22
33namespace NotificationChannels \PusherPushNotifications \Test ;
44
5- use Mockery ;
5+ use Illuminate \ Notifications \ Notifiable ;
66use NotificationChannels \PusherPushNotifications \PusherChannel ;
7+ use Illuminate \Notifications \Notification ;
8+ use NotificationChannels \PusherPushNotifications \PusherMessage ;
79use PHPUnit_Framework_TestCase ;
10+ use Mockery ;
811use Pusher ;
912
1013class ChannelTest extends PHPUnit_Framework_TestCase
1114{
12- /** @var Mockery\Mock */
13- protected $ pusher ;
14-
15- /** @var \NotificationChannels\PusherPushNotifications\PusherChannel */
16- protected $ channel ;
17-
1815 public function setUp ()
1916 {
2017 $ this ->pusher = Mockery::mock (Pusher::class);
2118
2219 $ this ->channel = new PusherChannel ($ this ->pusher );
20+
21+ $ this ->notification = new TestNotification ;
22+
23+ $ this ->notifiable = new TestNotifiable ;
2324 }
2425
2526 public function tearDown ()
@@ -32,10 +33,30 @@ public function tearDown()
3233 /** @test */
3334 public function it_can_send_a_notification ()
3435 {
35- /* TODO: revisit this test after L5.3 comes out */
36+ $ message = $ this ->notification ->toPushNotification ($ this ->notifiable );
37+
38+ $ data = $ message ->toArray ();
39+
40+ $ this ->pusher ->shouldReceive ('notify ' )->with ('interest_name ' , $ data , true )->andReturn (['status ' => 202 ]);
41+
42+ $ this ->channel ->send ($ this ->notifiable , $ this ->notification );
43+ }
44+ }
3645
37- //$this->pusher->shouldReceive('notify')->once()->andReturn(['response' => 200]);
46+ class TestNotifiable
47+ {
48+ use Notifiable;
3849
39- //$this->channel->send(new Notifiable(), new Notification());
50+ public function routeNotificationForPusherPushNotifications ()
51+ {
52+ return 'interest_name ' ;
53+ }
54+ }
55+
56+ class TestNotification extends Notification
57+ {
58+ public function toPushNotification ($ notifiable )
59+ {
60+ return new PusherMessage ();
4061 }
4162}
0 commit comments