Reduced amount of dead lines in tests

This commit is contained in:
Alejandro Celaya
2019-02-17 20:28:34 +01:00
parent 1bcd03b150
commit 687a1cc9c7
100 changed files with 481 additions and 938 deletions

View File

@@ -27,9 +27,7 @@ class DisableKeyCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function providedApiKeyIsDisabled()
{
$apiKey = 'abcd1234';
@@ -44,9 +42,7 @@ class DisableKeyCommandTest extends TestCase
$this->assertStringContainsString('API key "abcd1234" properly disabled', $output);
}
/**
* @test
*/
/** @test */
public function errorIsReturnedIfServiceThrowsException()
{
$apiKey = 'abcd1234';

View File

@@ -29,9 +29,7 @@ class GenerateKeyCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function noExpirationDateIsDefinedIfNotProvided()
{
$create = $this->apiKeyService->create(null)->willReturn(new ApiKey());
@@ -45,9 +43,7 @@ class GenerateKeyCommandTest extends TestCase
$create->shouldHaveBeenCalledOnce();
}
/**
* @test
*/
/** @test */
public function expirationDateIsDefinedIfProvided()
{
$this->apiKeyService->create(Argument::type(Chronos::class))->shouldBeCalledOnce()

View File

@@ -25,9 +25,7 @@ class GenerateCharsetCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function charactersAreGeneratedFromDefault()
{
$prefix = 'Character set: ';

View File

@@ -39,9 +39,7 @@ class GeneratePreviewCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function previewsForEveryUrlAreGenerated()
{
$paginator = $this->createPaginator([
@@ -69,9 +67,7 @@ class GeneratePreviewCommandTest extends TestCase
$generatePreview3->shouldHaveBeenCalledOnce();
}
/**
* @test
*/
/** @test */
public function exceptionWillOutputError()
{
$items = [

View File

@@ -34,9 +34,7 @@ class GenerateShortUrlCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function properShortCodeIsCreatedIfLongUrlIsCorrect()
{
$urlToShortCode = $this->urlShortener->urlToShortCode(Argument::cetera())->willReturn(
@@ -54,9 +52,7 @@ class GenerateShortUrlCommandTest extends TestCase
$urlToShortCode->shouldHaveBeenCalledOnce();
}
/**
* @test
*/
/** @test */
public function exceptionWhileParsingLongUrlOutputsError()
{
$this->urlShortener->urlToShortCode(Argument::cetera())->willThrow(new InvalidUrlException())
@@ -73,9 +69,7 @@ class GenerateShortUrlCommandTest extends TestCase
);
}
/**
* @test
*/
/** @test */
public function properlyProcessesProvidedTags()
{
$urlToShortCode = $this->urlShortener->urlToShortCode(

View File

@@ -37,9 +37,7 @@ class GetVisitsCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function noDateFlagsTriesToListWithoutDateRange()
{
$shortCode = 'abc123';
@@ -53,9 +51,7 @@ class GetVisitsCommandTest extends TestCase
]);
}
/**
* @test
*/
/** @test */
public function providingDateFlagsTheListGetsFiltered()
{
$shortCode = 'abc123';

View File

@@ -30,9 +30,7 @@ class ListShortUrlsCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function noInputCallsListJustOnce()
{
$this->shortUrlService->listShortUrls(1, null, [], null)->willReturn(new Paginator(new ArrayAdapter()))
@@ -42,9 +40,7 @@ class ListShortUrlsCommandTest extends TestCase
$this->commandTester->execute(['command' => 'shortcode:list']);
}
/**
* @test
*/
/** @test */
public function loadingMorePagesCallsListMoreTimes()
{
// The paginator will return more than one page
@@ -66,9 +62,7 @@ class ListShortUrlsCommandTest extends TestCase
$this->assertStringContainsString('Continue with page 4?', $output);
}
/**
* @test
*/
/** @test */
public function havingMorePagesButAnsweringNoCallsListJustOnce()
{
// The paginator will return more than one page
@@ -93,9 +87,7 @@ class ListShortUrlsCommandTest extends TestCase
$this->assertStringNotContainsString('Continue with page 3?', $output);
}
/**
* @test
*/
/** @test */
public function passingPageWillMakeListStartOnThatPage()
{
$page = 5;
@@ -109,9 +101,7 @@ class ListShortUrlsCommandTest extends TestCase
]);
}
/**
* @test
*/
/** @test */
public function ifTagsFlagIsProvidedTagsColumnIsIncluded()
{
$this->shortUrlService->listShortUrls(1, null, [], null)->willReturn(new Paginator(new ArrayAdapter()))

View File

@@ -31,9 +31,7 @@ class ResolveUrlCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function correctShortCodeResolvesUrl()
{
$shortCode = 'abc123';
@@ -50,9 +48,7 @@ class ResolveUrlCommandTest extends TestCase
$this->assertEquals('Long URL: ' . $expectedUrl . PHP_EOL, $output);
}
/**
* @test
*/
/** @test */
public function incorrectShortCodeOutputsErrorMessage()
{
$shortCode = 'abc123';
@@ -67,9 +63,7 @@ class ResolveUrlCommandTest extends TestCase
$this->assertStringContainsString('Provided short code "' . $shortCode . '" could not be found.', $output);
}
/**
* @test
*/
/** @test */
public function wrongShortCodeFormatOutputsErrorMessage()
{
$shortCode = 'abc123';

View File

@@ -30,9 +30,7 @@ class CreateTagCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function errorIsReturnedWhenNoTagsAreProvided()
{
$this->commandTester->execute([]);
@@ -41,9 +39,7 @@ class CreateTagCommandTest extends TestCase
$this->assertStringContainsString('You have to provide at least one tag name', $output);
}
/**
* @test
*/
/** @test */
public function serviceIsInvokedOnSuccess()
{
$tagNames = ['foo', 'bar'];

View File

@@ -31,9 +31,7 @@ class DeleteTagsCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function errorIsReturnedWhenNoTagsAreProvided()
{
$this->commandTester->execute([]);
@@ -42,9 +40,7 @@ class DeleteTagsCommandTest extends TestCase
$this->assertStringContainsString('You have to provide at least one tag name', $output);
}
/**
* @test
*/
/** @test */
public function serviceIsInvokedOnSuccess()
{
$tagNames = ['foo', 'bar'];

View File

@@ -32,9 +32,7 @@ class ListTagsCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function noTagsPrintsEmptyMessage()
{
/** @var MethodProphecy $listTags */
@@ -47,9 +45,7 @@ class ListTagsCommandTest extends TestCase
$listTags->shouldHaveBeenCalled();
}
/**
* @test
*/
/** @test */
public function listOfTagsIsPrinted()
{
/** @var MethodProphecy $listTags */

View File

@@ -33,9 +33,7 @@ class RenameTagCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function errorIsPrintedIfExceptionIsThrown()
{
$oldName = 'foo';
@@ -53,9 +51,7 @@ class RenameTagCommandTest extends TestCase
$renameTag->shouldHaveBeenCalled();
}
/**
* @test
*/
/** @test */
public function successIsPrintedIfNoErrorOccurs()
{
$oldName = 'foo';

View File

@@ -155,9 +155,7 @@ class ProcessVisitsCommandTest extends TestCase
$resolveIpLocation->shouldHaveBeenCalledOnce();
}
/**
* @test
*/
/** @test */
public function noActionIsPerformedIfLockIsAcquired()
{
$this->lock->acquire()->willReturn(false);

View File

@@ -30,9 +30,7 @@ class UpdateDbCommandTest extends TestCase
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
/** @test */
public function successMessageIsPrintedIfEverythingWorks()
{
$download = $this->dbUpdater->downloadFreshCopy(Argument::type('callable'))->will(function () {
@@ -45,9 +43,7 @@ class UpdateDbCommandTest extends TestCase
$download->shouldHaveBeenCalledOnce();
}
/**
* @test
*/
/** @test */
public function errorMessageIsPrintedIfAnExceptionIsThrown()
{
$download = $this->dbUpdater->downloadFreshCopy(Argument::type('callable'))->willThrow(RuntimeException::class);

View File

@@ -16,9 +16,7 @@ class ConfigProviderTest extends TestCase
$this->configProvider = new ConfigProvider();
}
/**
* @test
*/
/** @test */
public function confiIsProperlyReturned()
{
$config = ($this->configProvider)();

View File

@@ -23,18 +23,14 @@ class ApplicationFactoryTest extends TestCase
$this->factory = new ApplicationFactory();
}
/**
* @test
*/
/** @test */
public function serviceIsCreated()
{
$instance = ($this->factory)($this->createServiceManager(), '');
$this->assertInstanceOf(Application::class, $instance);
}
/**
* @test
*/
/** @test */
public function allCommandsWhichAreServicesAreAdded()
{
$sm = $this->createServiceManager([