getReference('abc123_short_url'); $manager->persist( Visit::forValidShortUrl($abcShortUrl, new Visitor('shlink-tests-agent', '', '44.55.66.77', '')), ); $manager->persist(Visit::forValidShortUrl( $abcShortUrl, new Visitor('shlink-tests-agent', 'https://google.com', '4.5.6.7', ''), )); $manager->persist(Visit::forValidShortUrl($abcShortUrl, new Visitor('shlink-tests-agent', '', '1.2.3.4', ''))); /** @var ShortUrl $defShortUrl */ $defShortUrl = $this->getReference('def456_short_url'); $manager->persist( Visit::forValidShortUrl($defShortUrl, new Visitor('cf-facebook', '', '127.0.0.1', '')), ); $manager->persist( Visit::forValidShortUrl($defShortUrl, new Visitor('shlink-tests-agent', 'https://app.shlink.io', '', '')), ); /** @var ShortUrl $ghiShortUrl */ $ghiShortUrl = $this->getReference('ghi789_short_url'); $manager->persist(Visit::forValidShortUrl($ghiShortUrl, new Visitor('shlink-tests-agent', '', '1.2.3.4', ''))); $manager->persist( Visit::forValidShortUrl($ghiShortUrl, new Visitor('shlink-tests-agent', 'https://app.shlink.io', '', '')), ); $manager->persist($this->setVisitDate( fn () => Visit::forBasePath(new Visitor('shlink-tests-agent', 'https://s.test', '1.2.3.4', '')), '2020-01-01', )); $manager->persist($this->setVisitDate( fn () => Visit::forRegularNotFound( new Visitor('shlink-tests-agent', 'https://s.test/foo/bar', '1.2.3.4', ''), ), '2020-02-01', )); $manager->persist($this->setVisitDate( fn () => Visit::forInvalidShortUrl(new Visitor('cf-facebook', 'https://s.test/foo', '1.2.3.4', 'foo.com')), '2020-03-01', )); $manager->flush(); } /** * @param callable(): Visit $createVisit */ private function setVisitDate(callable $createVisit, string $date): Visit { Chronos::setTestNow($date); $visit = $createVisit(); Chronos::setTestNow(); return $visit; } }