Ejemplo n.º 1
0
 /**
  * @param SessionStore $session
  * @param string $key
  */
 public function __construct(SessionStore $session, $key = 'notifications')
 {
     $this->session = $session;
     $this->key = $key;
     if ($this->session->has($this->newKey())) {
         $this->moveNewNotificationsToCurrent();
     }
 }
Ejemplo n.º 2
0
 function it_moves_the_notifications_from_new_to_current(SessionStore $session)
 {
     $notifications = [['type' => 'success', 'message' => 'It is successful'], ['type' => 'error', 'message' => 'It is an error']];
     $session->has('my-key.new')->willReturn(true);
     $session->get('my-key.new')->willReturn($notifications);
     $session->put('my-key.current', $notifications)->shouldBeCalled();
     $session->put('my-key.new', [])->shouldBeCalled();
     $session->get('my-key.current')->willReturn($notifications);
     $this->beConstructedWith($session, 'my-key');
     $this->getCurrentNotifications()->shouldHaveType(Notifications::class);
 }