Inheritance: extends Illuminate\Database\Eloquent\Model, use trait Fenos\Notifynder\Notifable
Example #1
0
 /**
  * get the last notification
  *
  * @method getLastNotification
  * @test
  */
 function it_get_last_notification()
 {
     $this->createMultipleNotifications();
     $lastNotification = $this->user->getLastNotification();
     $notification = Notification::orderBy('created_at', 'desc')->first();
     $this->assertEquals($notification->id, $lastNotification->id);
 }
Example #2
0
 /**
  * @test
  */
 public function it_get_paginated_notifications_of_the_current_user()
 {
     $this->createMultipleNotifications();
     $this->createMultipleNotifications();
     $this->createMultipleNotifications();
     $notifications = $this->user->getNotifications(5, true);
     $this->assertSame(3 * $this->multiNotificationsNumber, $notifications->total());
     $this->assertCount(5, $notifications);
 }
Example #3
0
 /**
  * It send multiple Notifications
  *
  * @method send
  * @group failing
  * @test
  */
 function it_send_multiple_notifications()
 {
     Factory::times(10)->create(User::class);
     $this->createCategory(['name' => 'me']);
     $allUsers = User::all();
     $this->notifynder->loop($allUsers, function ($builder, $user) {
         $builder->category('me')->url('you')->from(1)->to($user->id);
     })->send();
     // should send 10 notifications
     $notifications = Notification::all();
     $this->assertCount(10, $notifications);
 }