/** * @param Notification $notification * @return string */ private function renderNotification(Notification $notification) { $classNameSuffix = $this->getClassNameSuffix($notification->getType()); return <<<HTML <div class="alert alert-{$classNameSuffix}" role="alert"> {$notification->getMessage()} </div> HTML; }
/** * @param array $notifications * @return Notifications */ public static function mapFromArray(array $notifications) { $mapped = array_map(function (array $notification) { return Notification::fromArray($notification); }, $notifications); return new Notifications($mapped); }
function it_can_get_the_current_notifications() { $notification = Notification::success('It was successful'); $this->send($notification); $this->getCurrentNotifications()->shouldBe([]); }
function it_can_send_a_notification(Transport $transport) { $notification = Notification::success('It was successful'); $transport->send($notification)->shouldBeCalled(); $this->send($notification); }
function let() { $this->beConstructedWith([Notification::success('It is successful'), Notification::error('It is an error')]); }
function it_sends_the_notifications_to_the_session_store(SessionStore $session) { $notification = Notification::success('It was successful'); $session->push('my-key.new', ['type' => $notification->getType(), 'message' => $notification->getMessage()])->shouldBeCalled(); $this->send($notification); }
/** * @param Notification $notification * @return void */ public function send(Notification $notification) { $this->session->push($this->newKey(), ['type' => $notification->getType(), 'message' => $notification->getMessage()]); }
/** * @return Notifications */ private function createNotifications() { return new Notifications([Notification::success('It is successful'), Notification::error('It is an error'), Notification::warning('It is a warning'), Notification::info('It is info')]); }