mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-17 15:59:56 +03:00
Merge pull request #1415 from acelaya-forks/feature/yourls-domain
Feature/yourls domain
This commit is contained in:
commit
efb604a381
4 changed files with 19 additions and 11 deletions
|
@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
|||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
* *Nothing*
|
||||
* [#1294](https://github.com/shlinkio/shlink/issues/1294) Allowed to specify a specific domain when importing URLs from YOURLS.
|
||||
|
||||
### Changed
|
||||
* [#1359](https://github.com/shlinkio/shlink/issues/1359) Hidden database commands.
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
"shlinkio/shlink-common": "^4.4",
|
||||
"shlinkio/shlink-config": "^1.6",
|
||||
"shlinkio/shlink-event-dispatcher": "^2.3",
|
||||
"shlinkio/shlink-importer": "^2.5",
|
||||
"shlinkio/shlink-importer": "dev-main#75d50f9 as 3.0",
|
||||
"shlinkio/shlink-installer": "dev-develop#d02f256 as 7.1",
|
||||
"shlinkio/shlink-ip-geolocation": "^2.2",
|
||||
"symfony/console": "^6.0",
|
||||
|
|
|
@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface;
|
|||
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
||||
use Symfony\Component\Console\Style\StyleInterface;
|
||||
|
||||
|
@ -34,10 +35,10 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
|||
/**
|
||||
* @param iterable|ImportedShlinkUrl[] $shlinkUrls
|
||||
*/
|
||||
public function process(StyleInterface $io, iterable $shlinkUrls, array $params): void
|
||||
public function process(StyleInterface $io, iterable $shlinkUrls, ImportParams $params): void
|
||||
{
|
||||
$importShortCodes = $params['import_short_codes'];
|
||||
$source = $params['source'];
|
||||
$importShortCodes = $params->importShortCodes();
|
||||
$source = $params->source();
|
||||
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSources::SHLINK ? 10 : 100);
|
||||
|
||||
/** @var ImportedShlinkUrl $importedUrl */
|
||||
|
|
|
@ -20,6 +20,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Resolver\SimpleShortUrlRelationResolver;
|
|||
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkVisit;
|
||||
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
||||
use Symfony\Component\Console\Style\StyleInterface;
|
||||
|
||||
|
@ -32,8 +33,6 @@ class ImportedLinksProcessorTest extends TestCase
|
|||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private const PARAMS = ['import_short_codes' => true, 'source' => ImportSources::BITLY];
|
||||
|
||||
private ImportedLinksProcessor $processor;
|
||||
private ObjectProphecy $em;
|
||||
private ObjectProphecy $shortCodeHelper;
|
||||
|
@ -74,7 +73,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
||||
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
||||
|
||||
$this->processor->process($this->io->reveal(), $urls, self::PARAMS);
|
||||
$this->processor->process($this->io->reveal(), $urls, $this->buildParams());
|
||||
|
||||
$importedUrlExists->shouldHaveBeenCalledTimes($expectedCalls);
|
||||
$ensureUniqueness->shouldHaveBeenCalledTimes($expectedCalls);
|
||||
|
@ -104,7 +103,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
||||
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
||||
|
||||
$this->processor->process($this->io->reveal(), $urls, self::PARAMS);
|
||||
$this->processor->process($this->io->reveal(), $urls, $this->buildParams());
|
||||
|
||||
$importedUrlExists->shouldHaveBeenCalledTimes(count($urls));
|
||||
$ensureUniqueness->shouldHaveBeenCalledTimes(2);
|
||||
|
@ -141,7 +140,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||
});
|
||||
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
||||
|
||||
$this->processor->process($this->io->reveal(), $urls, self::PARAMS);
|
||||
$this->processor->process($this->io->reveal(), $urls, $this->buildParams());
|
||||
|
||||
$importedUrlExists->shouldHaveBeenCalledTimes(count($urls));
|
||||
$failingEnsureUniqueness->shouldHaveBeenCalledTimes(5);
|
||||
|
@ -167,7 +166,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||
$persistUrl = $this->em->persist(Argument::type(ShortUrl::class));
|
||||
$persistVisits = $this->em->persist(Argument::type(Visit::class));
|
||||
|
||||
$this->processor->process($this->io->reveal(), [$importedUrl], self::PARAMS);
|
||||
$this->processor->process($this->io->reveal(), [$importedUrl], $this->buildParams());
|
||||
|
||||
$findExisting->shouldHaveBeenCalledOnce();
|
||||
$ensureUniqueness->shouldHaveBeenCalledTimes($foundShortUrl === null ? 1 : 0);
|
||||
|
@ -214,4 +213,12 @@ class ImportedLinksProcessorTest extends TestCase
|
|||
])),
|
||||
];
|
||||
}
|
||||
|
||||
private function buildParams(): ImportParams
|
||||
{
|
||||
return ImportParams::fromSourceAndCallableMap(
|
||||
ImportSources::BITLY,
|
||||
['import_short_codes' => static fn () => true],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue