mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Converted visit types into enum
This commit is contained in:
@@ -17,6 +17,7 @@ use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToMercure;
|
||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
use Shlinkio\Shlink\Core\Visit\Model\VisitType;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
use Symfony\Component\Mercure\Update;
|
||||
|
||||
@@ -160,8 +161,8 @@ class NotifyVisitToMercureTest extends TestCase
|
||||
{
|
||||
$visitor = Visitor::emptyInstance();
|
||||
|
||||
yield Visit::TYPE_REGULAR_404 => [Visit::forRegularNotFound($visitor)];
|
||||
yield Visit::TYPE_INVALID_SHORT_URL => [Visit::forInvalidShortUrl($visitor)];
|
||||
yield Visit::TYPE_BASE_URL => [Visit::forBasePath($visitor)];
|
||||
yield VisitType::REGULAR_404->value => [Visit::forRegularNotFound($visitor)];
|
||||
yield VisitType::INVALID_SHORT_URL->value => [Visit::forInvalidShortUrl($visitor)];
|
||||
yield VisitType::BASE_URL->value => [Visit::forBasePath($visitor)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Transformer\ShortUrlDataTransformer;
|
||||
use Shlinkio\Shlink\Core\Visit\Model\VisitType;
|
||||
use Shlinkio\Shlink\Core\Visit\Transformer\OrphanVisitDataTransformer;
|
||||
|
||||
use function Shlinkio\Shlink\Common\json_decode;
|
||||
@@ -95,7 +96,7 @@ class MercureUpdatesGeneratorTest extends TestCase
|
||||
'date' => $orphanVisit->getDate()->toAtomString(),
|
||||
'potentialBot' => false,
|
||||
'visitedUrl' => $orphanVisit->visitedUrl(),
|
||||
'type' => $orphanVisit->type(),
|
||||
'type' => $orphanVisit->type()->value,
|
||||
],
|
||||
], json_decode($update->getData()));
|
||||
}
|
||||
@@ -104,8 +105,8 @@ class MercureUpdatesGeneratorTest extends TestCase
|
||||
{
|
||||
$visitor = Visitor::emptyInstance();
|
||||
|
||||
yield Visit::TYPE_REGULAR_404 => [Visit::forRegularNotFound($visitor)];
|
||||
yield Visit::TYPE_INVALID_SHORT_URL => [Visit::forInvalidShortUrl($visitor)];
|
||||
yield Visit::TYPE_BASE_URL => [Visit::forBasePath($visitor)];
|
||||
yield VisitType::REGULAR_404->value => [Visit::forRegularNotFound($visitor)];
|
||||
yield VisitType::INVALID_SHORT_URL->value => [Visit::forInvalidShortUrl($visitor)];
|
||||
yield VisitType::BASE_URL->value => [Visit::forBasePath($visitor)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\Entity\VisitLocation;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
use Shlinkio\Shlink\Core\Visit\Model\VisitType;
|
||||
use Shlinkio\Shlink\Core\Visit\Transformer\OrphanVisitDataTransformer;
|
||||
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
||||
|
||||
@@ -44,7 +45,7 @@ class OrphanVisitDataTransformerTest extends TestCase
|
||||
'visitLocation' => null,
|
||||
'potentialBot' => false,
|
||||
'visitedUrl' => '',
|
||||
'type' => Visit::TYPE_BASE_URL,
|
||||
'type' => VisitType::BASE_URL->value,
|
||||
],
|
||||
];
|
||||
yield 'invalid short url visit' => [
|
||||
@@ -60,7 +61,7 @@ class OrphanVisitDataTransformerTest extends TestCase
|
||||
'visitLocation' => null,
|
||||
'potentialBot' => false,
|
||||
'visitedUrl' => 'https://example.com/foo',
|
||||
'type' => Visit::TYPE_INVALID_SHORT_URL,
|
||||
'type' => VisitType::INVALID_SHORT_URL->value,
|
||||
],
|
||||
];
|
||||
yield 'regular 404 visit' => [
|
||||
@@ -78,7 +79,7 @@ class OrphanVisitDataTransformerTest extends TestCase
|
||||
'visitLocation' => $location,
|
||||
'potentialBot' => false,
|
||||
'visitedUrl' => 'https://doma.in/foo/bar',
|
||||
'type' => Visit::TYPE_REGULAR_404,
|
||||
'type' => VisitType::REGULAR_404->value,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user