mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-27 12:01:49 +03:00
Merge pull request #1498 from acelaya-forks/feature/update-shlink-deps
Feature/update shlink deps
This commit is contained in:
commit
6378e614b0
12 changed files with 82 additions and 80 deletions
|
@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* [#1495](https://github.com/shlinkio/shlink/issues/1495) Centralized how routes are configured to support multi-segment slugs.
|
* [#1495](https://github.com/shlinkio/shlink/issues/1495) Centralized how routes are configured to support multi-segment slugs.
|
||||||
|
* [#1497](https://github.com/shlinkio/shlink/issues/1497) Updated to latest shlink dependencies with support for PHP 8.1 only.
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
|
@ -43,12 +43,12 @@
|
||||||
"php-middleware/request-id": "^4.1",
|
"php-middleware/request-id": "^4.1",
|
||||||
"pugx/shortid-php": "^1.0",
|
"pugx/shortid-php": "^1.0",
|
||||||
"ramsey/uuid": "^4.3",
|
"ramsey/uuid": "^4.3",
|
||||||
"shlinkio/shlink-common": "dev-main#6163a03 as 5.0",
|
"shlinkio/shlink-common": "dev-main#5251f37 as 5.0",
|
||||||
"shlinkio/shlink-config": "^1.6",
|
"shlinkio/shlink-config": "^2.0",
|
||||||
"shlinkio/shlink-event-dispatcher": "^2.4",
|
"shlinkio/shlink-event-dispatcher": "^2.5",
|
||||||
"shlinkio/shlink-importer": "^3.0",
|
"shlinkio/shlink-importer": "^4.0",
|
||||||
"shlinkio/shlink-installer": "^8.0",
|
"shlinkio/shlink-installer": "dev-develop#c6032b1 as 8.1",
|
||||||
"shlinkio/shlink-ip-geolocation": "^2.2",
|
"shlinkio/shlink-ip-geolocation": "^3.0",
|
||||||
"symfony/console": "^6.1",
|
"symfony/console": "^6.1",
|
||||||
"symfony/filesystem": "^6.1",
|
"symfony/filesystem": "^6.1",
|
||||||
"symfony/lock": "^6.1",
|
"symfony/lock": "^6.1",
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^9.5",
|
||||||
"roave/security-advisories": "dev-master",
|
"roave/security-advisories": "dev-master",
|
||||||
"shlinkio/php-coding-standard": "~2.3.0",
|
"shlinkio/php-coding-standard": "~2.3.0",
|
||||||
"shlinkio/shlink-test-utils": "^3.0.1",
|
"shlinkio/shlink-test-utils": "^3.1.0",
|
||||||
"symfony/var-dumper": "^6.1",
|
"symfony/var-dumper": "^6.1",
|
||||||
"veewee/composer-run-parallel": "^1.1"
|
"veewee/composer-run-parallel": "^1.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -94,31 +94,31 @@ class ShortUrl extends AbstractEntity
|
||||||
): self {
|
): self {
|
||||||
$meta = [
|
$meta = [
|
||||||
ShortUrlInputFilter::VALIDATE_URL => false,
|
ShortUrlInputFilter::VALIDATE_URL => false,
|
||||||
ShortUrlInputFilter::LONG_URL => $url->longUrl(),
|
ShortUrlInputFilter::LONG_URL => $url->longUrl,
|
||||||
ShortUrlInputFilter::DOMAIN => $url->domain(),
|
ShortUrlInputFilter::DOMAIN => $url->domain,
|
||||||
ShortUrlInputFilter::TAGS => $url->tags(),
|
ShortUrlInputFilter::TAGS => $url->tags,
|
||||||
ShortUrlInputFilter::TITLE => $url->title(),
|
ShortUrlInputFilter::TITLE => $url->title,
|
||||||
ShortUrlInputFilter::MAX_VISITS => $url->meta()->maxVisits(),
|
ShortUrlInputFilter::MAX_VISITS => $url->meta->maxVisits,
|
||||||
];
|
];
|
||||||
if ($importShortCode) {
|
if ($importShortCode) {
|
||||||
$meta[ShortUrlInputFilter::CUSTOM_SLUG] = $url->shortCode();
|
$meta[ShortUrlInputFilter::CUSTOM_SLUG] = $url->shortCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
$instance = self::fromMeta(ShortUrlMeta::fromRawData($meta), $relationResolver);
|
$instance = self::fromMeta(ShortUrlMeta::fromRawData($meta), $relationResolver);
|
||||||
|
|
||||||
$validSince = $url->meta()->validSince();
|
$validSince = $url->meta->validSince;
|
||||||
if ($validSince !== null) {
|
if ($validSince !== null) {
|
||||||
$instance->validSince = Chronos::instance($validSince);
|
$instance->validSince = Chronos::instance($validSince);
|
||||||
}
|
}
|
||||||
|
|
||||||
$validUntil = $url->meta()->validUntil();
|
$validUntil = $url->meta->validUntil;
|
||||||
if ($validUntil !== null) {
|
if ($validUntil !== null) {
|
||||||
$instance->validUntil = Chronos::instance($validUntil);
|
$instance->validUntil = Chronos::instance($validUntil);
|
||||||
}
|
}
|
||||||
|
|
||||||
$instance->importSource = $url->source();
|
$instance->importSource = $url->source->value;
|
||||||
$instance->importOriginalShortCode = $url->shortCode();
|
$instance->importOriginalShortCode = $url->shortCode;
|
||||||
$instance->dateCreated = Chronos::instance($url->createdAt());
|
$instance->dateCreated = Chronos::instance($url->createdAt);
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,12 @@ class Visit extends AbstractEntity implements JsonSerializable
|
||||||
public static function fromImport(ShortUrl $shortUrl, ImportedShlinkVisit $importedVisit): self
|
public static function fromImport(ShortUrl $shortUrl, ImportedShlinkVisit $importedVisit): self
|
||||||
{
|
{
|
||||||
$instance = new self($shortUrl, VisitType::IMPORTED);
|
$instance = new self($shortUrl, VisitType::IMPORTED);
|
||||||
$instance->userAgent = $importedVisit->userAgent();
|
$instance->userAgent = $importedVisit->userAgent;
|
||||||
$instance->potentialBot = isCrawler($instance->userAgent);
|
$instance->potentialBot = isCrawler($instance->userAgent);
|
||||||
$instance->referer = $importedVisit->referer();
|
$instance->referer = $importedVisit->referer;
|
||||||
$instance->date = Chronos::instance($importedVisit->date());
|
$instance->date = Chronos::instance($importedVisit->date);
|
||||||
|
|
||||||
$importedLocation = $importedVisit->location();
|
$importedLocation = $importedVisit->location;
|
||||||
$instance->visitLocation = $importedLocation !== null ? VisitLocation::fromImport($importedLocation) : null;
|
$instance->visitLocation = $importedLocation !== null ? VisitLocation::fromImport($importedLocation) : null;
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
|
|
|
@ -28,13 +28,13 @@ class VisitLocation extends AbstractEntity implements JsonSerializable
|
||||||
{
|
{
|
||||||
$instance = new self();
|
$instance = new self();
|
||||||
|
|
||||||
$instance->countryCode = $location->countryCode();
|
$instance->countryCode = $location->countryCode;
|
||||||
$instance->countryName = $location->countryName();
|
$instance->countryName = $location->countryName;
|
||||||
$instance->regionName = $location->regionName();
|
$instance->regionName = $location->regionName;
|
||||||
$instance->cityName = $location->city();
|
$instance->cityName = $location->city;
|
||||||
$instance->latitude = $location->latitude();
|
$instance->latitude = $location->latitude;
|
||||||
$instance->longitude = $location->longitude();
|
$instance->longitude = $location->longitude;
|
||||||
$instance->timezone = $location->timeZone();
|
$instance->timezone = $location->timeZone;
|
||||||
$instance->computeIsEmpty();
|
$instance->computeIsEmpty();
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
|
@ -44,13 +44,13 @@ class VisitLocation extends AbstractEntity implements JsonSerializable
|
||||||
{
|
{
|
||||||
$instance = new self();
|
$instance = new self();
|
||||||
|
|
||||||
$instance->countryCode = $location->countryCode();
|
$instance->countryCode = $location->countryCode;
|
||||||
$instance->countryName = $location->countryName();
|
$instance->countryName = $location->countryName;
|
||||||
$instance->regionName = $location->regionName();
|
$instance->regionName = $location->regionName;
|
||||||
$instance->cityName = $location->cityName();
|
$instance->cityName = $location->cityName;
|
||||||
$instance->latitude = $location->latitude();
|
$instance->latitude = $location->latitude;
|
||||||
$instance->longitude = $location->longitude();
|
$instance->longitude = $location->longitude;
|
||||||
$instance->timezone = $location->timeZone();
|
$instance->timezone = $location->timezone;
|
||||||
$instance->computeIsEmpty();
|
$instance->computeIsEmpty();
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
|
|
|
@ -38,6 +38,6 @@ class NonUniqueSlugException extends InvalidArgumentException implements Problem
|
||||||
|
|
||||||
public static function fromImport(ImportedShlinkUrl $importedUrl): self
|
public static function fromImport(ImportedShlinkUrl $importedUrl): self
|
||||||
{
|
{
|
||||||
return self::fromSlug($importedUrl->shortCode(), $importedUrl->domain());
|
return self::fromSlug($importedUrl->shortCode, $importedUrl->domain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||||
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||||
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||||
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||||
use Symfony\Component\Console\Style\OutputStyle;
|
use Symfony\Component\Console\Style\OutputStyle;
|
||||||
use Symfony\Component\Console\Style\StyleInterface;
|
use Symfony\Component\Console\Style\StyleInterface;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
@ -26,10 +26,10 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||||
private ShortUrlRepositoryInterface $shortUrlRepo;
|
private ShortUrlRepositoryInterface $shortUrlRepo;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
private ShortUrlRelationResolverInterface $relationResolver,
|
private readonly ShortUrlRelationResolverInterface $relationResolver,
|
||||||
private ShortCodeUniquenessHelperInterface $shortCodeHelper,
|
private readonly ShortCodeUniquenessHelperInterface $shortCodeHelper,
|
||||||
private DoctrineBatchHelperInterface $batchHelper,
|
private readonly DoctrineBatchHelperInterface $batchHelper,
|
||||||
) {
|
) {
|
||||||
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);
|
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);
|
||||||
}
|
}
|
||||||
|
@ -39,19 +39,19 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||||
*/
|
*/
|
||||||
public function process(StyleInterface $io, iterable $shlinkUrls, ImportParams $params): void
|
public function process(StyleInterface $io, iterable $shlinkUrls, ImportParams $params): void
|
||||||
{
|
{
|
||||||
$importShortCodes = $params->importShortCodes();
|
$importShortCodes = $params->importShortCodes;
|
||||||
$source = $params->source();
|
$source = $params->source;
|
||||||
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSources::SHLINK ? 10 : 100);
|
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSource::SHLINK ? 10 : 100);
|
||||||
|
|
||||||
/** @var ImportedShlinkUrl $importedUrl */
|
/** @var ImportedShlinkUrl $importedUrl */
|
||||||
foreach ($iterable as $importedUrl) {
|
foreach ($iterable as $importedUrl) {
|
||||||
$skipOnShortCodeConflict = static fn (): bool => $io->choice(sprintf(
|
$skipOnShortCodeConflict = static fn (): bool => $io->choice(sprintf(
|
||||||
'Failed to import URL "%s" because its short-code "%s" is already in use. Do you want to generate '
|
'Failed to import URL "%s" because its short-code "%s" is already in use. Do you want to generate '
|
||||||
. 'a new one or skip it?',
|
. 'a new one or skip it?',
|
||||||
$importedUrl->longUrl(),
|
$importedUrl->longUrl,
|
||||||
$importedUrl->shortCode(),
|
$importedUrl->shortCode,
|
||||||
), ['Generate new short-code', 'Skip'], 1) === 'Skip';
|
), ['Generate new short-code', 'Skip'], 1) === 'Skip';
|
||||||
$longUrl = $importedUrl->longUrl();
|
$longUrl = $importedUrl->longUrl;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$shortUrlImporting = $this->resolveShortUrl($importedUrl, $importShortCodes, $skipOnShortCodeConflict);
|
$shortUrlImporting = $this->resolveShortUrl($importedUrl, $importShortCodes, $skipOnShortCodeConflict);
|
||||||
|
@ -68,7 +68,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$resultMessage = $shortUrlImporting->importVisits($importedUrl->visits(), $this->em);
|
$resultMessage = $shortUrlImporting->importVisits($importedUrl->visits, $this->em);
|
||||||
$io->text(sprintf('%s: %s', $longUrl, $resultMessage));
|
$io->text(sprintf('%s: %s', $longUrl, $resultMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ final class ShortUrlImporting
|
||||||
$importedVisits = 0;
|
$importedVisits = 0;
|
||||||
foreach ($visits as $importedVisit) {
|
foreach ($visits as $importedVisit) {
|
||||||
// Skip visits which are older than the most recent already imported visit's date
|
// Skip visits which are older than the most recent already imported visit's date
|
||||||
if ($mostRecentImportedDate?->gte(Chronos::instance($importedVisit->date()))) {
|
if ($mostRecentImportedDate?->gte(Chronos::instance($importedVisit->date))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,12 +284,12 @@ class ShortUrlRepository extends EntitySpecificationRepository implements ShortU
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('s');
|
$qb = $this->createQueryBuilder('s');
|
||||||
$qb->andWhere($qb->expr()->eq('s.importOriginalShortCode', ':shortCode'))
|
$qb->andWhere($qb->expr()->eq('s.importOriginalShortCode', ':shortCode'))
|
||||||
->setParameter('shortCode', $url->shortCode())
|
->setParameter('shortCode', $url->shortCode)
|
||||||
->andWhere($qb->expr()->eq('s.importSource', ':importSource'))
|
->andWhere($qb->expr()->eq('s.importSource', ':importSource'))
|
||||||
->setParameter('importSource', $url->source())
|
->setParameter('importSource', $url->source->value)
|
||||||
->setMaxResults(1);
|
->setMaxResults(1);
|
||||||
|
|
||||||
$this->whereDomainIs($qb, $url->domain());
|
$this->whereDomainIs($qb, $url->domain);
|
||||||
|
|
||||||
return $qb->getQuery()->getOneOrNullResult();
|
return $qb->getQuery()->getOneOrNullResult();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Persistence\ShortUrlsCountFiltering;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Persistence\ShortUrlsListFiltering;
|
use Shlinkio\Shlink\Core\ShortUrl\Persistence\ShortUrlsListFiltering;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Resolver\PersistenceShortUrlRelationResolver;
|
use Shlinkio\Shlink\Core\ShortUrl\Resolver\PersistenceShortUrlRelationResolver;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||||
|
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||||
use Shlinkio\Shlink\Rest\ApiKey\Model\ApiKeyMeta;
|
use Shlinkio\Shlink\Rest\ApiKey\Model\ApiKeyMeta;
|
||||||
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
|
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
|
||||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||||
|
@ -601,7 +602,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||||
public function importedShortUrlsAreFoundWhenExpected(): void
|
public function importedShortUrlsAreFoundWhenExpected(): void
|
||||||
{
|
{
|
||||||
$buildImported = static fn (string $shortCode, ?String $domain = null) =>
|
$buildImported = static fn (string $shortCode, ?String $domain = null) =>
|
||||||
new ImportedShlinkUrl('', 'foo', [], Chronos::now(), $domain, $shortCode, null);
|
new ImportedShlinkUrl(ImportSource::BITLY, 'foo', [], Chronos::now(), $domain, $shortCode, null);
|
||||||
|
|
||||||
$shortUrlWithoutDomain = ShortUrl::fromImport($buildImported('my-cool-slug'), true);
|
$shortUrlWithoutDomain = ShortUrl::fromImport($buildImported('my-cool-slug'), true);
|
||||||
$this->getEntityManager()->persist($shortUrlWithoutDomain);
|
$this->getEntityManager()->persist($shortUrlWithoutDomain);
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Shlinkio\Shlink\Core\Exception\ShortCodeCannotBeRegeneratedException;
|
||||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||||
use Shlinkio\Shlink\Core\Validation\ShortUrlInputFilter;
|
use Shlinkio\Shlink\Core\Validation\ShortUrlInputFilter;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||||
|
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||||
|
|
||||||
use function Functional\map;
|
use function Functional\map;
|
||||||
use function range;
|
use function range;
|
||||||
|
@ -63,9 +64,10 @@ class ShortUrlTest extends TestCase
|
||||||
public function provideValidShortUrls(): iterable
|
public function provideValidShortUrls(): iterable
|
||||||
{
|
{
|
||||||
yield 'no custom slug' => [ShortUrl::createEmpty()];
|
yield 'no custom slug' => [ShortUrl::createEmpty()];
|
||||||
yield 'imported with custom slug' => [
|
yield 'imported with custom slug' => [ShortUrl::fromImport(
|
||||||
ShortUrl::fromImport(new ImportedShlinkUrl('', '', [], Chronos::now(), null, 'custom-slug', null), true),
|
new ImportedShlinkUrl(ImportSource::BITLY, '', [], Chronos::now(), null, 'custom-slug', null),
|
||||||
];
|
true,
|
||||||
|
)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@ use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkVisit;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkVisit;
|
||||||
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||||
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||||
use Symfony\Component\Console\Style\StyleInterface;
|
use Symfony\Component\Console\Style\StyleInterface;
|
||||||
|
|
||||||
use function count;
|
use function count;
|
||||||
|
@ -64,9 +64,9 @@ class ImportedLinksProcessorTest extends TestCase
|
||||||
public function newUrlsWithNoErrorsAreAllPersisted(): void
|
public function newUrlsWithNoErrorsAreAllPersisted(): void
|
||||||
{
|
{
|
||||||
$urls = [
|
$urls = [
|
||||||
new ImportedShlinkUrl('', 'foo', [], Chronos::now(), null, 'foo', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'foo', [], Chronos::now(), null, 'foo', null),
|
||||||
new ImportedShlinkUrl('', 'bar', [], Chronos::now(), null, 'bar', 'foo'),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'bar', [], Chronos::now(), null, 'bar', 'foo'),
|
||||||
new ImportedShlinkUrl('', 'baz', [], Chronos::now(), null, 'baz', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz', [], Chronos::now(), null, 'baz', null),
|
||||||
];
|
];
|
||||||
$expectedCalls = count($urls);
|
$expectedCalls = count($urls);
|
||||||
|
|
||||||
|
@ -86,9 +86,9 @@ class ImportedLinksProcessorTest extends TestCase
|
||||||
public function newUrlsWithErrorsAreSkipped(): void
|
public function newUrlsWithErrorsAreSkipped(): void
|
||||||
{
|
{
|
||||||
$urls = [
|
$urls = [
|
||||||
new ImportedShlinkUrl('', 'foo', [], Chronos::now(), null, 'foo', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'foo', [], Chronos::now(), null, 'foo', null),
|
||||||
new ImportedShlinkUrl('', 'bar', [], Chronos::now(), null, 'bar', 'foo'),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'bar', [], Chronos::now(), null, 'bar', 'foo'),
|
||||||
new ImportedShlinkUrl('', 'baz', [], Chronos::now(), null, 'baz', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz', [], Chronos::now(), null, 'baz', null),
|
||||||
];
|
];
|
||||||
|
|
||||||
$importedUrlExists = $this->repo->findOneByImportedUrl(Argument::cetera())->willReturn(null);
|
$importedUrlExists = $this->repo->findOneByImportedUrl(Argument::cetera())->willReturn(null);
|
||||||
|
@ -117,11 +117,11 @@ class ImportedLinksProcessorTest extends TestCase
|
||||||
public function alreadyImportedUrlsAreSkipped(): void
|
public function alreadyImportedUrlsAreSkipped(): void
|
||||||
{
|
{
|
||||||
$urls = [
|
$urls = [
|
||||||
new ImportedShlinkUrl('', 'foo', [], Chronos::now(), null, 'foo', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'foo', [], Chronos::now(), null, 'foo', null),
|
||||||
new ImportedShlinkUrl('', 'bar', [], Chronos::now(), null, 'bar', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'bar', [], Chronos::now(), null, 'bar', null),
|
||||||
new ImportedShlinkUrl('', 'baz', [], Chronos::now(), null, 'baz', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz', [], Chronos::now(), null, 'baz', null),
|
||||||
new ImportedShlinkUrl('', 'baz2', [], Chronos::now(), null, 'baz2', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz2', [], Chronos::now(), null, 'baz2', null),
|
||||||
new ImportedShlinkUrl('', 'baz3', [], Chronos::now(), null, 'baz3', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz3', [], Chronos::now(), null, 'baz3', null),
|
||||||
];
|
];
|
||||||
|
|
||||||
$importedUrlExists = $this->repo->findOneByImportedUrl(Argument::cetera())->will(
|
$importedUrlExists = $this->repo->findOneByImportedUrl(Argument::cetera())->will(
|
||||||
|
@ -129,7 +129,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||||
/** @var ImportedShlinkUrl $url */
|
/** @var ImportedShlinkUrl $url */
|
||||||
[$url] = $args;
|
[$url] = $args;
|
||||||
|
|
||||||
return contains(['foo', 'baz2', 'baz3'], $url->longUrl()) ? ShortUrl::fromImport($url, true) : null;
|
return contains(['foo', 'baz2', 'baz3'], $url->longUrl) ? ShortUrl::fromImport($url, true) : null;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
||||||
|
@ -148,11 +148,11 @@ class ImportedLinksProcessorTest extends TestCase
|
||||||
public function nonUniqueShortCodesAreAskedToUser(): void
|
public function nonUniqueShortCodesAreAskedToUser(): void
|
||||||
{
|
{
|
||||||
$urls = [
|
$urls = [
|
||||||
new ImportedShlinkUrl('', 'foo', [], Chronos::now(), null, 'foo', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'foo', [], Chronos::now(), null, 'foo', null),
|
||||||
new ImportedShlinkUrl('', 'bar', [], Chronos::now(), null, 'bar', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'bar', [], Chronos::now(), null, 'bar', null),
|
||||||
new ImportedShlinkUrl('', 'baz', [], Chronos::now(), null, 'baz', 'foo'),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz', [], Chronos::now(), null, 'baz', 'foo'),
|
||||||
new ImportedShlinkUrl('', 'baz2', [], Chronos::now(), null, 'baz2', null),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz2', [], Chronos::now(), null, 'baz2', null),
|
||||||
new ImportedShlinkUrl('', 'baz3', [], Chronos::now(), null, 'baz3', 'bar'),
|
new ImportedShlinkUrl(ImportSource::BITLY, 'baz3', [], Chronos::now(), null, 'baz3', 'bar'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$importedUrlExists = $this->repo->findOneByImportedUrl(Argument::cetera())->willReturn(null);
|
$importedUrlExists = $this->repo->findOneByImportedUrl(Argument::cetera())->willReturn(null);
|
||||||
|
@ -210,7 +210,8 @@ class ImportedLinksProcessorTest extends TestCase
|
||||||
public function provideUrlsWithVisits(): iterable
|
public function provideUrlsWithVisits(): iterable
|
||||||
{
|
{
|
||||||
$now = Chronos::now();
|
$now = Chronos::now();
|
||||||
$createImportedUrl = fn (array $visits) => new ImportedShlinkUrl('', 's', [], $now, null, 's', null, $visits);
|
$createImportedUrl = static fn (array $visits) =>
|
||||||
|
new ImportedShlinkUrl(ImportSource::BITLY, 's', [], $now, null, 's', null, $visits);
|
||||||
|
|
||||||
yield 'new short URL' => [$createImportedUrl([
|
yield 'new short URL' => [$createImportedUrl([
|
||||||
new ImportedShlinkVisit('', '', $now, null),
|
new ImportedShlinkVisit('', '', $now, null),
|
||||||
|
@ -248,9 +249,6 @@ class ImportedLinksProcessorTest extends TestCase
|
||||||
|
|
||||||
private function buildParams(): ImportParams
|
private function buildParams(): ImportParams
|
||||||
{
|
{
|
||||||
return ImportParams::fromSourceAndCallableMap(
|
return ImportSource::BITLY->toParamsWithCallableMap(['import_short_codes' => static fn () => true]);
|
||||||
ImportSources::BITLY,
|
|
||||||
['import_short_codes' => static fn () => true],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue