2019-01-27 05:14:18 -06:00
|
|
|
<?php
|
2019-10-05 10:26:10 -05:00
|
|
|
|
2019-01-27 05:14:18 -06:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkioApiTest\Shlink\Rest\Fixtures;
|
|
|
|
|
|
|
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
|
|
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
2019-12-16 14:46:27 -06:00
|
|
|
use Doctrine\Persistence\ObjectManager;
|
2019-01-27 05:14:18 -06:00
|
|
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
|
|
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
|
|
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
|
|
|
|
|
|
|
class VisitsFixture extends AbstractFixture implements DependentFixtureInterface
|
|
|
|
{
|
|
|
|
public function getDependencies(): array
|
|
|
|
{
|
|
|
|
return [ShortUrlsFixture::class];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function load(ObjectManager $manager): void
|
|
|
|
{
|
|
|
|
/** @var ShortUrl $abcShortUrl */
|
|
|
|
$abcShortUrl = $this->getReference('abc123_short_url');
|
2021-02-07 14:31:12 -06:00
|
|
|
$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', '')));
|
2019-01-27 05:14:18 -06:00
|
|
|
|
|
|
|
/** @var ShortUrl $defShortUrl */
|
|
|
|
$defShortUrl = $this->getReference('def456_short_url');
|
2021-02-07 14:31:12 -06:00
|
|
|
$manager->persist(
|
|
|
|
Visit::forValidShortUrl($defShortUrl, new Visitor('shlink-tests-agent', '', '127.0.0.1', '')),
|
|
|
|
);
|
|
|
|
$manager->persist(
|
|
|
|
Visit::forValidShortUrl($defShortUrl, new Visitor('shlink-tests-agent', 'https://app.shlink.io', '', '')),
|
|
|
|
);
|
2019-01-27 05:14:18 -06:00
|
|
|
|
2021-01-05 12:29:42 -06:00
|
|
|
/** @var ShortUrl $ghiShortUrl */
|
|
|
|
$ghiShortUrl = $this->getReference('ghi789_short_url');
|
2021-02-07 14:31:12 -06:00
|
|
|
$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', '', '')),
|
|
|
|
);
|
2020-02-02 03:46:38 -06:00
|
|
|
|
2021-02-08 15:44:58 -06:00
|
|
|
$manager->persist(Visit::forBasePath(new Visitor('shlink-tests-agent', 'https://doma.in', '1.2.3.4', '')));
|
|
|
|
$manager->persist(
|
|
|
|
Visit::forRegularNotFound(new Visitor('shlink-tests-agent', 'https://doma.in/foo/bar', '1.2.3.4', '')),
|
|
|
|
);
|
|
|
|
$manager->persist(
|
|
|
|
Visit::forInvalidShortUrl(new Visitor('shlink-tests-agent', 'https://doma.in/foo', '1.2.3.4', '')),
|
|
|
|
);
|
|
|
|
|
2019-01-27 05:14:18 -06:00
|
|
|
$manager->flush();
|
|
|
|
}
|
|
|
|
}
|