mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Updated to coding standard v2.1
This commit is contained in:
@@ -29,7 +29,7 @@ class GenerateKeyCommandTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function noExpirationDateIsDefinedIfNotProvided()
|
||||
public function noExpirationDateIsDefinedIfNotProvided(): void
|
||||
{
|
||||
$create = $this->apiKeyService->create(null)->willReturn(new ApiKey());
|
||||
|
||||
@@ -41,7 +41,7 @@ class GenerateKeyCommandTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function expirationDateIsDefinedIfProvided()
|
||||
public function expirationDateIsDefinedIfProvided(): void
|
||||
{
|
||||
$this->apiKeyService->create(Argument::type(Chronos::class))->shouldBeCalledOnce()
|
||||
->willReturn(new ApiKey());
|
||||
|
||||
@@ -33,7 +33,7 @@ class CreateDatabaseCommandTest extends TestCase
|
||||
$locker = $this->prophesize(LockFactory::class);
|
||||
$lock = $this->prophesize(LockInterface::class);
|
||||
$lock->acquire(Argument::any())->willReturn(true);
|
||||
$lock->release()->will(function () {
|
||||
$lock->release()->will(function (): void {
|
||||
});
|
||||
$locker->createLock(Argument::cetera())->willReturn($lock->reveal());
|
||||
|
||||
@@ -55,7 +55,7 @@ class CreateDatabaseCommandTest extends TestCase
|
||||
$this->processHelper->reveal(),
|
||||
$phpExecutableFinder->reveal(),
|
||||
$this->regularConn->reveal(),
|
||||
$this->noDbNameConn->reveal()
|
||||
$this->noDbNameConn->reveal(),
|
||||
);
|
||||
$app = new Application();
|
||||
$app->add($command);
|
||||
@@ -69,7 +69,7 @@ class CreateDatabaseCommandTest extends TestCase
|
||||
$shlinkDatabase = 'shlink_database';
|
||||
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
|
||||
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', $shlinkDatabase, 'bar']);
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
|
||||
});
|
||||
$listTables = $this->schemaManager->listTableNames()->willReturn(['foo_table', 'bar_table']);
|
||||
|
||||
@@ -89,7 +89,7 @@ class CreateDatabaseCommandTest extends TestCase
|
||||
$shlinkDatabase = 'shlink_database';
|
||||
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
|
||||
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', 'bar']);
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
|
||||
});
|
||||
$listTables = $this->schemaManager->listTableNames()->willReturn(['foo_table', 'bar_table']);
|
||||
|
||||
@@ -107,7 +107,7 @@ class CreateDatabaseCommandTest extends TestCase
|
||||
$shlinkDatabase = 'shlink_database';
|
||||
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
|
||||
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', $shlinkDatabase, 'bar']);
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
|
||||
});
|
||||
$listTables = $this->schemaManager->listTableNames()->willReturn([]);
|
||||
$runCommand = $this->processHelper->mustRun(Argument::type(OutputInterface::class), [
|
||||
@@ -136,7 +136,7 @@ class CreateDatabaseCommandTest extends TestCase
|
||||
$shlinkDatabase = 'shlink_database';
|
||||
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
|
||||
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', 'bar']);
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
|
||||
$createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
|
||||
});
|
||||
$listTables = $this->schemaManager->listTableNames()->willReturn(['foo_table', 'bar_table']);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class MigrateDatabaseCommandTest extends TestCase
|
||||
$locker = $this->prophesize(LockFactory::class);
|
||||
$lock = $this->prophesize(LockInterface::class);
|
||||
$lock->acquire(Argument::any())->willReturn(true);
|
||||
$lock->release()->will(function () {
|
||||
$lock->release()->will(function (): void {
|
||||
});
|
||||
$locker->createLock(Argument::cetera())->willReturn($lock->reveal());
|
||||
|
||||
@@ -38,7 +38,7 @@ class MigrateDatabaseCommandTest extends TestCase
|
||||
$command = new MigrateDatabaseCommand(
|
||||
$locker->reveal(),
|
||||
$this->processHelper->reveal(),
|
||||
$phpExecutableFinder->reveal()
|
||||
$phpExecutableFinder->reveal(),
|
||||
);
|
||||
$app = new Application();
|
||||
$app->add($command);
|
||||
|
||||
@@ -38,7 +38,7 @@ class DeleteShortUrlCommandTest extends TestCase
|
||||
public function successMessageIsPrintedIfUrlIsProperlyDeleted(): void
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->will(function () {
|
||||
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->will(function (): void {
|
||||
});
|
||||
|
||||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
@@ -46,7 +46,7 @@ class DeleteShortUrlCommandTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(
|
||||
sprintf('Short URL with short code "%s" successfully deleted.', $shortCode),
|
||||
$output
|
||||
$output,
|
||||
);
|
||||
$deleteByShortCode->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class DeleteShortUrlCommandTest extends TestCase
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->willThrow(
|
||||
Exception\ShortUrlNotFoundException::fromNotFoundShortCode($shortCode)
|
||||
Exception\ShortUrlNotFoundException::fromNotFoundShortCode($shortCode),
|
||||
);
|
||||
|
||||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
@@ -77,13 +77,13 @@ class DeleteShortUrlCommandTest extends TestCase
|
||||
): void {
|
||||
$shortCode = 'abc123';
|
||||
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, Argument::type('bool'))->will(
|
||||
function (array $args) use ($shortCode) {
|
||||
function (array $args) use ($shortCode): void {
|
||||
$ignoreThreshold = array_pop($args);
|
||||
|
||||
if (!$ignoreThreshold) {
|
||||
throw Exception\DeleteShortUrlException::fromVisitsThreshold(10, $shortCode);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
$this->commandTester->setInputs($retryAnswer);
|
||||
|
||||
@@ -92,7 +92,7 @@ class DeleteShortUrlCommandTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(sprintf(
|
||||
'Impossible to delete short URL with short code "%s" since it has more than "10" visits.',
|
||||
$shortCode
|
||||
$shortCode,
|
||||
), $output);
|
||||
$this->assertStringContainsString($expectedMessage, $output);
|
||||
$deleteByShortCode->shouldHaveBeenCalledTimes($expectedDeleteCalls);
|
||||
@@ -110,7 +110,7 @@ class DeleteShortUrlCommandTest extends TestCase
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->willThrow(
|
||||
Exception\DeleteShortUrlException::fromVisitsThreshold(10, $shortCode)
|
||||
Exception\DeleteShortUrlException::fromVisitsThreshold(10, $shortCode),
|
||||
);
|
||||
$this->commandTester->setInputs(['no']);
|
||||
|
||||
@@ -119,7 +119,7 @@ class DeleteShortUrlCommandTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(sprintf(
|
||||
'Impossible to delete short URL with short code "%s" since it has more than "10" visits.',
|
||||
$shortCode
|
||||
$shortCode,
|
||||
), $output);
|
||||
$this->assertStringContainsString('Short URL was not deleted.', $output);
|
||||
$deleteByShortCode->shouldHaveBeenCalledOnce();
|
||||
|
||||
@@ -72,7 +72,7 @@ class GenerateShortUrlCommandTest extends TestCase
|
||||
public function providingNonUniqueSlugOutputsError(): void
|
||||
{
|
||||
$urlToShortCode = $this->urlShortener->urlToShortCode(Argument::cetera())->willThrow(
|
||||
NonUniqueSlugException::fromSlug('my-slug')
|
||||
NonUniqueSlugException::fromSlug('my-slug'),
|
||||
);
|
||||
|
||||
$this->commandTester->execute(['longUrl' => 'http://domain.com/invalid', '--customSlug' => 'my-slug']);
|
||||
@@ -93,7 +93,7 @@ class GenerateShortUrlCommandTest extends TestCase
|
||||
Assert::assertEquals(['foo', 'bar', 'baz', 'boo', 'zar'], $tags);
|
||||
return $tags;
|
||||
}),
|
||||
Argument::cetera()
|
||||
Argument::cetera(),
|
||||
)->willReturn($shortUrl);
|
||||
|
||||
$this->commandTester->execute([
|
||||
|
||||
@@ -43,7 +43,7 @@ class GetVisitsCommandTest extends TestCase
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$this->visitsTracker->info($shortCode, new VisitsParams(new DateRange(null, null)))->willReturn(
|
||||
new Paginator(new ArrayAdapter([]))
|
||||
new Paginator(new ArrayAdapter([])),
|
||||
)->shouldBeCalledOnce();
|
||||
|
||||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
@@ -57,7 +57,7 @@ class GetVisitsCommandTest extends TestCase
|
||||
$endDate = '2016-02-01';
|
||||
$this->visitsTracker->info(
|
||||
$shortCode,
|
||||
new VisitsParams(new DateRange(Chronos::parse($startDate), Chronos::parse($endDate)))
|
||||
new VisitsParams(new DateRange(Chronos::parse($startDate), Chronos::parse($endDate))),
|
||||
)
|
||||
->willReturn(new Paginator(new ArrayAdapter([])))
|
||||
->shouldBeCalledOnce();
|
||||
@@ -86,7 +86,7 @@ class GetVisitsCommandTest extends TestCase
|
||||
$info->shouldHaveBeenCalledOnce();
|
||||
$this->assertStringContainsString(
|
||||
sprintf('Ignored provided "startDate" since its value "%s" is not a valid date', $startDate),
|
||||
$output
|
||||
$output,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ class GetVisitsCommandTest extends TestCase
|
||||
$this->visitsTracker->info($shortCode, Argument::any())->willReturn(
|
||||
new Paginator(new ArrayAdapter([
|
||||
(new Visit(new ShortUrl(''), new Visitor('bar', 'foo', '')))->locate(
|
||||
new VisitLocation(new Location('', 'Spain', '', '', 0, 0, ''))
|
||||
new VisitLocation(new Location('', 'Spain', '', '', 0, 0, '')),
|
||||
),
|
||||
]))
|
||||
])),
|
||||
)->shouldBeCalledOnce();
|
||||
|
||||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
|
||||
@@ -162,6 +162,7 @@ class ListShortUrlsCommandTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array|null $expectedOrderBy
|
||||
* @test
|
||||
* @dataProvider provideOrderBy
|
||||
*/
|
||||
|
||||
@@ -40,7 +40,7 @@ class DeleteTagsCommandTest extends TestCase
|
||||
public function serviceIsInvokedOnSuccess(): void
|
||||
{
|
||||
$tagNames = ['foo', 'bar'];
|
||||
$deleteTags = $this->tagService->deleteTags($tagNames)->will(function () {
|
||||
$deleteTags = $this->tagService->deleteTags($tagNames)->will(function (): void {
|
||||
});
|
||||
|
||||
$this->commandTester->execute([
|
||||
|
||||
@@ -45,7 +45,7 @@ class LocateVisitsCommandTest extends TestCase
|
||||
$this->locker = $this->prophesize(Lock\LockFactory::class);
|
||||
$this->lock = $this->prophesize(Lock\LockInterface::class);
|
||||
$this->lock->acquire(false)->willReturn(true);
|
||||
$this->lock->release()->will(function () {
|
||||
$this->lock->release()->will(function (): void {
|
||||
});
|
||||
$this->locker->createLock(Argument::type('string'), 90.0, false)->willReturn($this->lock->reveal());
|
||||
|
||||
@@ -53,7 +53,7 @@ class LocateVisitsCommandTest extends TestCase
|
||||
$this->visitService->reveal(),
|
||||
$this->ipResolver->reveal(),
|
||||
$this->locker->reveal(),
|
||||
$this->dbUpdater->reveal()
|
||||
$this->dbUpdater->reveal(),
|
||||
);
|
||||
$app = new Application();
|
||||
$app->add($command);
|
||||
@@ -68,16 +68,16 @@ class LocateVisitsCommandTest extends TestCase
|
||||
$location = new VisitLocation(Location::emptyInstance());
|
||||
|
||||
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(
|
||||
function (array $args) use ($visit, $location) {
|
||||
function (array $args) use ($visit, $location): void {
|
||||
$firstCallback = array_shift($args);
|
||||
$firstCallback($visit);
|
||||
|
||||
$secondCallback = array_shift($args);
|
||||
$secondCallback($location, $visit);
|
||||
}
|
||||
},
|
||||
);
|
||||
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willReturn(
|
||||
Location::emptyInstance()
|
||||
Location::emptyInstance(),
|
||||
);
|
||||
|
||||
$this->commandTester->execute([]);
|
||||
@@ -98,16 +98,16 @@ class LocateVisitsCommandTest extends TestCase
|
||||
$location = new VisitLocation(Location::emptyInstance());
|
||||
|
||||
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(
|
||||
function (array $args) use ($visit, $location) {
|
||||
function (array $args) use ($visit, $location): void {
|
||||
$firstCallback = array_shift($args);
|
||||
$firstCallback($visit);
|
||||
|
||||
$secondCallback = array_shift($args);
|
||||
$secondCallback($location, $visit);
|
||||
}
|
||||
},
|
||||
);
|
||||
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willReturn(
|
||||
Location::emptyInstance()
|
||||
Location::emptyInstance(),
|
||||
);
|
||||
|
||||
$this->commandTester->execute([], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE]);
|
||||
@@ -137,13 +137,13 @@ class LocateVisitsCommandTest extends TestCase
|
||||
$location = new VisitLocation(Location::emptyInstance());
|
||||
|
||||
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(
|
||||
function (array $args) use ($visit, $location) {
|
||||
function (array $args) use ($visit, $location): void {
|
||||
$firstCallback = array_shift($args);
|
||||
$firstCallback($visit);
|
||||
|
||||
$secondCallback = array_shift($args);
|
||||
$secondCallback($location, $visit);
|
||||
}
|
||||
},
|
||||
);
|
||||
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willThrow(WrongIpException::class);
|
||||
|
||||
@@ -161,7 +161,7 @@ class LocateVisitsCommandTest extends TestCase
|
||||
{
|
||||
$this->lock->acquire(false)->willReturn(false);
|
||||
|
||||
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function () {
|
||||
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function (): void {
|
||||
});
|
||||
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willReturn([]);
|
||||
|
||||
@@ -170,7 +170,7 @@ class LocateVisitsCommandTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(
|
||||
sprintf('Command "%s" is already in progress. Skipping.', LocateVisitsCommand::NAME),
|
||||
$output
|
||||
$output,
|
||||
);
|
||||
$locateVisits->shouldNotHaveBeenCalled();
|
||||
$resolveIpLocation->shouldNotHaveBeenCalled();
|
||||
@@ -182,17 +182,17 @@ class LocateVisitsCommandTest extends TestCase
|
||||
*/
|
||||
public function showsProperMessageWhenGeoLiteUpdateFails(bool $olderDbExists, string $expectedMessage): void
|
||||
{
|
||||
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function () {
|
||||
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function (): void {
|
||||
});
|
||||
$checkDbUpdate = $this->dbUpdater->checkDbUpdate(Argument::cetera())->will(
|
||||
function (array $args) use ($olderDbExists) {
|
||||
function (array $args) use ($olderDbExists): void {
|
||||
[$mustBeUpdated, $handleProgress] = $args;
|
||||
|
||||
$mustBeUpdated($olderDbExists);
|
||||
$handleProgress(100, 50);
|
||||
|
||||
throw GeolocationDbUpdateFailedException::create($olderDbExists);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$this->commandTester->execute([]);
|
||||
@@ -200,7 +200,7 @@ class LocateVisitsCommandTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(
|
||||
sprintf('%s GeoLite2 database...', $olderDbExists ? 'Updating' : 'Downloading'),
|
||||
$output
|
||||
$output,
|
||||
);
|
||||
$this->assertStringContainsString($expectedMessage, $output);
|
||||
$locateVisits->shouldHaveBeenCalledTimes((int) $olderDbExists);
|
||||
|
||||
@@ -17,7 +17,7 @@ class ConfigProviderTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function confiIsProperlyReturned()
|
||||
public function confiIsProperlyReturned(): void
|
||||
{
|
||||
$config = ($this->configProvider)();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class GeolocationDbUpdateFailedExceptionTest extends TestCase
|
||||
$this->assertEquals($olderDbExists, $e->olderDbExists());
|
||||
$this->assertEquals(
|
||||
'An error occurred while updating geolocation database, and an older version could not be found',
|
||||
$e->getMessage()
|
||||
$e->getMessage(),
|
||||
);
|
||||
$this->assertEquals(0, $e->getCode());
|
||||
$this->assertEquals($prev, $e->getPrevious());
|
||||
|
||||
@@ -59,7 +59,7 @@ class ApplicationFactoryTest extends TestCase
|
||||
$command->getDefinition()->willReturn($name);
|
||||
$command->isEnabled()->willReturn(true);
|
||||
$command->getAliases()->willReturn([]);
|
||||
$command->setApplication(Argument::type(Application::class))->willReturn(function () {
|
||||
$command->setApplication(Argument::type(Application::class))->willReturn(function (): void {
|
||||
});
|
||||
|
||||
return $command;
|
||||
|
||||
@@ -36,14 +36,14 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$this->locker = $this->prophesize(Lock\LockFactory::class);
|
||||
$this->lock = $this->prophesize(Lock\LockInterface::class);
|
||||
$this->lock->acquire(true)->willReturn(true);
|
||||
$this->lock->release()->will(function () {
|
||||
$this->lock->release()->will(function (): void {
|
||||
});
|
||||
$this->locker->createLock(Argument::type('string'))->willReturn($this->lock->reveal());
|
||||
|
||||
$this->geolocationDbUpdater = new GeolocationDbUpdater(
|
||||
$this->dbUpdater->reveal(),
|
||||
$this->geoLiteDbReader->reveal(),
|
||||
$this->locker->reveal()
|
||||
$this->locker->reveal(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
'node_count' => 1,
|
||||
'record_size' => 4,
|
||||
]));
|
||||
$download = $this->dbUpdater->downloadFreshCopy(null)->will(function () {
|
||||
$download = $this->dbUpdater->downloadFreshCopy(null)->will(function (): void {
|
||||
});
|
||||
|
||||
$this->geolocationDbUpdater->checkDbUpdate();
|
||||
|
||||
@@ -33,7 +33,7 @@ class ShlinkTableTest extends TestCase
|
||||
$footerTitle = 'Footer';
|
||||
|
||||
$setStyle = $this->baseTable->setStyle(Argument::type(TableStyle::class))->willReturn(
|
||||
$this->baseTable->reveal()
|
||||
$this->baseTable->reveal(),
|
||||
);
|
||||
$setHeaders = $this->baseTable->setHeaders($headers)->willReturn($this->baseTable->reveal());
|
||||
$setRows = $this->baseTable->setRows($rows)->willReturn($this->baseTable->reveal());
|
||||
|
||||
Reference in New Issue
Block a user