function TestSaveVisit() { $link = $this->shortenerService->shorten("http://yahoo.com"); $visit = new Visit(); $visit->setLink($link); $visit->setCountry("FR"); $visit->setIp('87.248.120.148'); $this->shortenerService->saveVisit($visit); $this->assertInternalType("int", $visit->getId()); }
function addVisit(Link $link, $ip) { $visit = new Visit(); $visit->setIp($ip); $visit->setCreatedAt(new \DateTime()); $visit->setCountry($this->getCountryFromIp($ip)); $link->addVisit($visit); $this->em->persist($visit); $this->em->flush(); return $link; }