Updated to coding standard v2.1

This commit is contained in:
Alejandro Celaya
2020-01-01 20:48:31 +01:00
parent 1070482629
commit 50100c251e
112 changed files with 253 additions and 300 deletions

View File

@@ -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();

View File

@@ -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([

View File

@@ -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]);

View File

@@ -162,6 +162,7 @@ class ListShortUrlsCommandTest extends TestCase
}
/**
* @param string|array|null $expectedOrderBy
* @test
* @dataProvider provideOrderBy
*/