Example #1
0
 /** @test */
 function it_send_with_an_custom_sender()
 {
     $this->senders->extend('sendCustom', function ($notification, $app) {
         return new CustomDefaultSender($notification, $app->make('notifynder'));
     });
     $category_name = 'my.category';
     $this->createCategory(['name' => $category_name]);
     $singleNotification = $this->builder->category($category_name)->to(1)->from(2)->url('www.notifynder.io')->toArray();
     $this->senders->sendCustom($singleNotification);
     $this->assertCount(1, Notification::all());
 }
 /** @test */
 function it_delete_all_notification_expired_by_category_name()
 {
     $category = $this->createCategory(['name' => 'test']);
     $this->createNotification(['category_id' => $category->id, 'expire_time' => Carbon\Carbon::now()->subDays(1)]);
     $this->createNotification(['category_id' => $category->id, 'expire_time' => Carbon\Carbon::now()->subDays(1)]);
     $this->createNotification(['category_id' => $category->id, 'expire_time' => Carbon\Carbon::now()->subDays(1)]);
     $this->createNotification(['category_id' => $category->id, 'expire_time' => Carbon\Carbon::now()->addDays(1)]);
     $this->notificationRepo->deleteByCategory($category->name, true);
     $this->assertCount(1, Notification::all());
 }
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);
 }
 /** @test */
 public function it_delete_2_notification_to_be_sent_trought_the_handler()
 {
     $this->dispatcher->delegate(['activation' => 'notify@userActivated', 'confirmation' => 'notify@userMultiple']);
     $notification = \Fenos\Notifynder\Models\Notification::all();
     $this->assertCount(3, $notification);
 }