public function it_find_visitor_when_visitor_sid_isset_on_session(VisitorRepository $visitorRepository, Request $request) { $visitor = new VisitorModel(); $visitor->sid = str_random(25); $request->session()->set('visitor_log_sid', $visitor->sid); $request->session()->has('visitor_log_sid')->shouldBeCalled()->willReturn(true); $request->session()->get('visitor_log_sid')->shouldBeCalled()->willReturn($visitor->sid); $visitorRepository->find($visitor->sid)->shouldBeCalled()->willReturn($visitor); $this->findCurrent()->shouldReturnAnInstanceOf(VisitorModel::class); }
/** * @return bool */ public function getUseragent() { $visitor = $this->findByIp($this->request->getClientIp()); if (!$visitor) { return false; } $this->getSession()->put('visitor_log_sid', $visitor->sid); $sid = $this->getSession()->get('visitor_log_sid'); return $this->visitorRepository->getUseragent($sid); }