/** @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()); }
/** * Extend a custom sender method * * @param $name * @param callable $registrar * @return $this */ public function extend($name, $registrar) { if (!starts_with($name, 'send')) { $error = "The sender method must start with [send]"; throw new InvalidArgumentException($error); } $this->notifynderSender->extend($name, $registrar); return $this; }