Merge pull request #353 from acelaya/feature/testing-tools

Updated testing tools
This commit is contained in:
Alejandro Celaya 2019-02-16 20:50:22 +01:00 committed by GitHub
commit 25927a296d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
91 changed files with 192 additions and 192 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ data/shlink-tests.db
data/GeoLite2-City.mmdb data/GeoLite2-City.mmdb
docs/swagger-ui* docs/swagger-ui*
docker-compose.override.yml docker-compose.override.yml
.phpunit.result.cache

View file

@ -10,5 +10,5 @@ echo 'Starting server...'
vendor/bin/zend-expressive-swoole start -d vendor/bin/zend-expressive-swoole start -d
sleep 2 sleep 2
vendor/bin/phpunit --order-by=random -c phpunit-api.xml vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox
vendor/bin/zend-expressive-swoole stop vendor/bin/zend-expressive-swoole stop

View file

@ -55,8 +55,8 @@
"filp/whoops": "^2.0", "filp/whoops": "^2.0",
"infection/infection": "^0.11.0", "infection/infection": "^0.11.0",
"phpstan/phpstan": "^0.10.0", "phpstan/phpstan": "^0.10.0",
"phpunit/phpcov": "^5.0", "phpunit/phpcov": "^6.0@dev || ^5.0",
"phpunit/phpunit": "^7.3", "phpunit/phpunit": "^8.0 || ^7.5",
"roave/security-advisories": "dev-master", "roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~1.0.0", "shlinkio/php-coding-standard": "~1.0.0",
"symfony/dotenv": "^4.2", "symfony/dotenv": "^4.2",
@ -112,9 +112,9 @@
"@test:db", "@test:db",
"@test:api" "@test:api"
], ],
"test:unit": "phpdbg -qrr vendor/bin/phpunit --order-by=random --coverage-php build/coverage-unit.cov", "test:unit": "phpdbg -qrr vendor/bin/phpunit --order-by=random --coverage-php build/coverage-unit.cov --testdox",
"test:unit:ci": "phpdbg -qrr vendor/bin/phpunit --order-by=random --coverage-php build/coverage-unit.cov --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/phpunit.junit.xml", "test:unit:ci": "phpdbg -qrr vendor/bin/phpunit --order-by=random --coverage-php build/coverage-unit.cov --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/phpunit.junit.xml --testdox",
"test:db": "APP_ENV=test phpdbg -qrr vendor/bin/phpunit --order-by=random -c phpunit-db.xml --coverage-php build/coverage-db.cov", "test:db": "APP_ENV=test phpdbg -qrr vendor/bin/phpunit --order-by=random -c phpunit-db.xml --coverage-php build/coverage-db.cov --testdox",
"test:api": "bin/test/run-api-tests.sh", "test:api": "bin/test/run-api-tests.sh",
"test:pretty": [ "test:pretty": [
@ -147,7 +147,8 @@
"test:unit:pretty": "<fg=blue;options=bold>Runs unit test suites and generates an HTML code coverage report</>", "test:unit:pretty": "<fg=blue;options=bold>Runs unit test suites and generates an HTML code coverage report</>",
"infect": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing</>", "infect": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing</>",
"infect:ci": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing with existing reports and logs</>", "infect:ci": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing with existing reports and logs</>",
"infect:show": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing and shows applied mutators</>" "infect:show": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing and shows applied mutators</>",
"infect:test": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing</>"
}, },
"config": { "config": {
"sort-packages": true "sort-packages": true

View file

@ -18,7 +18,7 @@ class DisableKeyCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $apiKeyService; private $apiKeyService;
public function setUp() public function setUp(): void
{ {
$this->apiKeyService = $this->prophesize(ApiKeyService::class); $this->apiKeyService = $this->prophesize(ApiKeyService::class);
$command = new DisableKeyCommand($this->apiKeyService->reveal()); $command = new DisableKeyCommand($this->apiKeyService->reveal());
@ -41,7 +41,7 @@ class DisableKeyCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('API key "abcd1234" properly disabled', $output); $this->assertStringContainsString('API key "abcd1234" properly disabled', $output);
} }
/** /**
@ -58,7 +58,7 @@ class DisableKeyCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('API key "abcd1234" does not exist.', $output); $this->assertStringContainsString('API key "abcd1234" does not exist.', $output);
$disable->shouldHaveBeenCalledOnce(); $disable->shouldHaveBeenCalledOnce();
} }
} }

View file

@ -20,7 +20,7 @@ class GenerateKeyCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $apiKeyService; private $apiKeyService;
public function setUp() public function setUp(): void
{ {
$this->apiKeyService = $this->prophesize(ApiKeyService::class); $this->apiKeyService = $this->prophesize(ApiKeyService::class);
$command = new GenerateKeyCommand($this->apiKeyService->reveal()); $command = new GenerateKeyCommand($this->apiKeyService->reveal());
@ -41,7 +41,7 @@ class GenerateKeyCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Generated API key: ', $output); $this->assertStringContainsString('Generated API key: ', $output);
$create->shouldHaveBeenCalledOnce(); $create->shouldHaveBeenCalledOnce();
} }

View file

@ -18,7 +18,7 @@ class ListKeysCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $apiKeyService; private $apiKeyService;
public function setUp() public function setUp(): void
{ {
$this->apiKeyService = $this->prophesize(ApiKeyService::class); $this->apiKeyService = $this->prophesize(ApiKeyService::class);
$command = new ListKeysCommand($this->apiKeyService->reveal()); $command = new ListKeysCommand($this->apiKeyService->reveal());
@ -27,10 +27,8 @@ class ListKeysCommandTest extends TestCase
$this->commandTester = new CommandTester($command); $this->commandTester = new CommandTester($command);
} }
/** /** @test */
* @test public function everythingIsListedIfEnabledOnlyIsNotProvided(): void
*/
public function everythingIsListedIfEnabledOnlyIsNotProvided()
{ {
$this->apiKeyService->listKeys(false)->willReturn([ $this->apiKeyService->listKeys(false)->willReturn([
new ApiKey(), new ApiKey(),
@ -43,17 +41,15 @@ class ListKeysCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Key', $output); $this->assertStringContainsString('Key', $output);
$this->assertContains('Is enabled', $output); $this->assertStringContainsString('Is enabled', $output);
$this->assertContains(' +++ ', $output); $this->assertStringContainsString(' +++ ', $output);
$this->assertNotContains(' --- ', $output); $this->assertStringNotContainsString(' --- ', $output);
$this->assertContains('Expiration date', $output); $this->assertStringContainsString('Expiration date', $output);
} }
/** /** @test */
* @test public function onlyEnabledKeysAreListedIfEnabledOnlyIsProvided(): void
*/
public function onlyEnabledKeysAreListedIfEnabledOnlyIsProvided()
{ {
$this->apiKeyService->listKeys(true)->willReturn([ $this->apiKeyService->listKeys(true)->willReturn([
(new ApiKey())->disable(), (new ApiKey())->disable(),
@ -66,10 +62,10 @@ class ListKeysCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Key', $output); $this->assertStringContainsString('Key', $output);
$this->assertNotContains('Is enabled', $output); $this->assertStringNotContainsString('Is enabled', $output);
$this->assertNotContains(' +++ ', $output); $this->assertStringNotContainsString(' +++ ', $output);
$this->assertNotContains(' --- ', $output); $this->assertStringNotContainsString(' --- ', $output);
$this->assertContains('Expiration date', $output); $this->assertStringContainsString('Expiration date', $output);
} }
} }

View file

@ -16,7 +16,7 @@ class GenerateCharsetCommandTest extends TestCase
/** @var CommandTester */ /** @var CommandTester */
private $commandTester; private $commandTester;
public function setUp() public function setUp(): void
{ {
$command = new GenerateCharsetCommand(); $command = new GenerateCharsetCommand();
$app = new Application(); $app = new Application();
@ -38,7 +38,7 @@ class GenerateCharsetCommandTest extends TestCase
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
// Both default character set and the new one should have the same length // Both default character set and the new one should have the same length
$this->assertContains($prefix, $output); $this->assertStringContainsString($prefix, $output);
} }
protected function orderStringLetters($string) protected function orderStringLetters($string)

View file

@ -21,7 +21,7 @@ class DeleteShortCodeCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $service; private $service;
public function setUp() public function setUp(): void
{ {
$this->service = $this->prophesize(DeleteShortUrlServiceInterface::class); $this->service = $this->prophesize(DeleteShortUrlServiceInterface::class);
@ -44,7 +44,10 @@ class DeleteShortCodeCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]); $this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains(sprintf('Short URL with short code "%s" successfully deleted.', $shortCode), $output); $this->assertStringContainsString(
sprintf('Short URL with short code "%s" successfully deleted.', $shortCode),
$output
);
$deleteByShortCode->shouldHaveBeenCalledOnce(); $deleteByShortCode->shouldHaveBeenCalledOnce();
} }
@ -61,7 +64,7 @@ class DeleteShortCodeCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]); $this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains(sprintf('Provided short code "%s" could not be found.', $shortCode), $output); $this->assertStringContainsString(sprintf('Provided short code "%s" could not be found.', $shortCode), $output);
$deleteByShortCode->shouldHaveBeenCalledOnce(); $deleteByShortCode->shouldHaveBeenCalledOnce();
} }
@ -85,11 +88,14 @@ class DeleteShortCodeCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]); $this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains(sprintf( $this->assertStringContainsString(sprintf(
'It was not possible to delete the short URL with short code "%s" because it has more than 10 visits.', 'It was not possible to delete the short URL with short code "%s" because it has more than 10 visits.',
$shortCode $shortCode
), $output); ), $output);
$this->assertContains(sprintf('Short URL with short code "%s" successfully deleted.', $shortCode), $output); $this->assertStringContainsString(
sprintf('Short URL with short code "%s" successfully deleted.', $shortCode),
$output
);
$deleteByShortCode->shouldHaveBeenCalledTimes(2); $deleteByShortCode->shouldHaveBeenCalledTimes(2);
} }
@ -107,11 +113,11 @@ class DeleteShortCodeCommandTest extends TestCase
$this->commandTester->execute(['shortCode' => $shortCode]); $this->commandTester->execute(['shortCode' => $shortCode]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains(sprintf( $this->assertStringContainsString(sprintf(
'It was not possible to delete the short URL with short code "%s" because it has more than 10 visits.', 'It was not possible to delete the short URL with short code "%s" because it has more than 10 visits.',
$shortCode $shortCode
), $output); ), $output);
$this->assertContains('Short URL was not deleted.', $output); $this->assertStringContainsString('Short URL was not deleted.', $output);
$deleteByShortCode->shouldHaveBeenCalledOnce(); $deleteByShortCode->shouldHaveBeenCalledOnce();
} }
} }

View file

@ -27,7 +27,7 @@ class GeneratePreviewCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $shortUrlService; private $shortUrlService;
public function setUp() public function setUp(): void
{ {
$this->previewGenerator = $this->prophesize(PreviewGenerator::class); $this->previewGenerator = $this->prophesize(PreviewGenerator::class);
$this->shortUrlService = $this->prophesize(ShortUrlService::class); $this->shortUrlService = $this->prophesize(ShortUrlService::class);
@ -60,10 +60,10 @@ class GeneratePreviewCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Processing URL http://foo.com', $output); $this->assertStringContainsString('Processing URL http://foo.com', $output);
$this->assertContains('Processing URL https://bar.com', $output); $this->assertStringContainsString('Processing URL https://bar.com', $output);
$this->assertContains('Processing URL http://baz.com/something', $output); $this->assertStringContainsString('Processing URL http://baz.com/something', $output);
$this->assertContains('Finished processing all URLs', $output); $this->assertStringContainsString('Finished processing all URLs', $output);
$generatePreview1->shouldHaveBeenCalledOnce(); $generatePreview1->shouldHaveBeenCalledOnce();
$generatePreview2->shouldHaveBeenCalledOnce(); $generatePreview2->shouldHaveBeenCalledOnce();
$generatePreview3->shouldHaveBeenCalledOnce(); $generatePreview3->shouldHaveBeenCalledOnce();

View file

@ -22,7 +22,7 @@ class GenerateShortUrlCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $urlShortener; private $urlShortener;
public function setUp() public function setUp(): void
{ {
$this->urlShortener = $this->prophesize(UrlShortener::class); $this->urlShortener = $this->prophesize(UrlShortener::class);
$command = new GenerateShortUrlCommand($this->urlShortener->reveal(), [ $command = new GenerateShortUrlCommand($this->urlShortener->reveal(), [
@ -50,7 +50,7 @@ class GenerateShortUrlCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('http://foo.com/abc123', $output); $this->assertStringContainsString('http://foo.com/abc123', $output);
$urlToShortCode->shouldHaveBeenCalledOnce(); $urlToShortCode->shouldHaveBeenCalledOnce();
} }
@ -67,7 +67,7 @@ class GenerateShortUrlCommandTest extends TestCase
'longUrl' => 'http://domain.com/invalid', 'longUrl' => 'http://domain.com/invalid',
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains( $this->assertStringContainsString(
'Provided URL "http://domain.com/invalid" is invalid.', 'Provided URL "http://domain.com/invalid" is invalid.',
$output $output
); );
@ -94,7 +94,7 @@ class GenerateShortUrlCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('http://foo.com/abc123', $output); $this->assertStringContainsString('http://foo.com/abc123', $output);
$urlToShortCode->shouldHaveBeenCalledOnce(); $urlToShortCode->shouldHaveBeenCalledOnce();
} }
} }

View file

@ -27,7 +27,7 @@ class GetVisitsCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $visitsTracker; private $visitsTracker;
public function setUp() public function setUp(): void
{ {
$this->visitsTracker = $this->prophesize(VisitsTrackerInterface::class); $this->visitsTracker = $this->prophesize(VisitsTrackerInterface::class);
$command = new GetVisitsCommand($this->visitsTracker->reveal()); $command = new GetVisitsCommand($this->visitsTracker->reveal());
@ -94,8 +94,8 @@ class GetVisitsCommandTest extends TestCase
'shortCode' => $shortCode, 'shortCode' => $shortCode,
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('foo', $output); $this->assertStringContainsString('foo', $output);
$this->assertContains('Spain', $output); $this->assertStringContainsString('Spain', $output);
$this->assertContains('bar', $output); $this->assertStringContainsString('bar', $output);
} }
} }

View file

@ -21,7 +21,7 @@ class ListShortUrlsCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $shortUrlService; private $shortUrlService;
public function setUp() public function setUp(): void
{ {
$this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class); $this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class);
$app = new Application(); $app = new Application();
@ -61,9 +61,9 @@ class ListShortUrlsCommandTest extends TestCase
$this->commandTester->execute(['command' => 'shortcode:list']); $this->commandTester->execute(['command' => 'shortcode:list']);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Continue with page 2?', $output); $this->assertStringContainsString('Continue with page 2?', $output);
$this->assertContains('Continue with page 3?', $output); $this->assertStringContainsString('Continue with page 3?', $output);
$this->assertContains('Continue with page 4?', $output); $this->assertStringContainsString('Continue with page 4?', $output);
} }
/** /**
@ -84,13 +84,13 @@ class ListShortUrlsCommandTest extends TestCase
$this->commandTester->execute(['command' => 'shortcode:list']); $this->commandTester->execute(['command' => 'shortcode:list']);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('url_1', $output); $this->assertStringContainsString('url_1', $output);
$this->assertContains('url_9', $output); $this->assertStringContainsString('url_9', $output);
$this->assertNotContains('url_10', $output); $this->assertStringNotContainsString('url_10', $output);
$this->assertNotContains('url_20', $output); $this->assertStringNotContainsString('url_20', $output);
$this->assertNotContains('url_30', $output); $this->assertStringNotContainsString('url_30', $output);
$this->assertContains('Continue with page 2?', $output); $this->assertStringContainsString('Continue with page 2?', $output);
$this->assertNotContains('Continue with page 3?', $output); $this->assertStringNotContainsString('Continue with page 3?', $output);
} }
/** /**
@ -123,6 +123,6 @@ class ListShortUrlsCommandTest extends TestCase
'--showTags' => true, '--showTags' => true,
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Tags', $output); $this->assertStringContainsString('Tags', $output);
} }
} }

View file

@ -21,7 +21,7 @@ class ResolveUrlCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $urlShortener; private $urlShortener;
public function setUp() public function setUp(): void
{ {
$this->urlShortener = $this->prophesize(UrlShortener::class); $this->urlShortener = $this->prophesize(UrlShortener::class);
$command = new ResolveUrlCommand($this->urlShortener->reveal()); $command = new ResolveUrlCommand($this->urlShortener->reveal());
@ -64,7 +64,7 @@ class ResolveUrlCommandTest extends TestCase
'shortCode' => $shortCode, 'shortCode' => $shortCode,
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Provided short code "' . $shortCode . '" could not be found.', $output); $this->assertStringContainsString('Provided short code "' . $shortCode . '" could not be found.', $output);
} }
/** /**
@ -81,6 +81,6 @@ class ResolveUrlCommandTest extends TestCase
'shortCode' => $shortCode, 'shortCode' => $shortCode,
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Provided short code "' . $shortCode . '" has an invalid format.', $output); $this->assertStringContainsString('Provided short code "' . $shortCode . '" has an invalid format.', $output);
} }
} }

View file

@ -19,7 +19,7 @@ class CreateTagCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
@ -38,7 +38,7 @@ class CreateTagCommandTest extends TestCase
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('You have to provide at least one tag name', $output); $this->assertStringContainsString('You have to provide at least one tag name', $output);
} }
/** /**
@ -55,7 +55,7 @@ class CreateTagCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Tags properly created', $output); $this->assertStringContainsString('Tags properly created', $output);
$createTags->shouldHaveBeenCalled(); $createTags->shouldHaveBeenCalled();
} }
} }

View file

@ -20,7 +20,7 @@ class DeleteTagsCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
@ -39,7 +39,7 @@ class DeleteTagsCommandTest extends TestCase
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('You have to provide at least one tag name', $output); $this->assertStringContainsString('You have to provide at least one tag name', $output);
} }
/** /**
@ -57,7 +57,7 @@ class DeleteTagsCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Tags properly deleted', $output); $this->assertStringContainsString('Tags properly deleted', $output);
$deleteTags->shouldHaveBeenCalled(); $deleteTags->shouldHaveBeenCalled();
} }
} }

View file

@ -21,7 +21,7 @@ class ListTagsCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
@ -43,7 +43,7 @@ class ListTagsCommandTest extends TestCase
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('No tags yet', $output); $this->assertStringContainsString('No tags yet', $output);
$listTags->shouldHaveBeenCalled(); $listTags->shouldHaveBeenCalled();
} }
@ -61,8 +61,8 @@ class ListTagsCommandTest extends TestCase
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('foo', $output); $this->assertStringContainsString('foo', $output);
$this->assertContains('bar', $output); $this->assertStringContainsString('bar', $output);
$listTags->shouldHaveBeenCalled(); $listTags->shouldHaveBeenCalled();
} }
} }

View file

@ -22,7 +22,7 @@ class RenameTagCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
@ -49,7 +49,7 @@ class RenameTagCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('A tag with name "foo" was not found', $output); $this->assertStringContainsString('A tag with name "foo" was not found', $output);
$renameTag->shouldHaveBeenCalled(); $renameTag->shouldHaveBeenCalled();
} }
@ -69,7 +69,7 @@ class RenameTagCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Tag properly renamed', $output); $this->assertStringContainsString('Tag properly renamed', $output);
$renameTag->shouldHaveBeenCalled(); $renameTag->shouldHaveBeenCalled();
} }
} }

View file

@ -37,7 +37,7 @@ class ProcessVisitsCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $lock; private $lock;
public function setUp() public function setUp(): void
{ {
$this->visitService = $this->prophesize(VisitService::class); $this->visitService = $this->prophesize(VisitService::class);
$this->ipResolver = $this->prophesize(IpApiLocationResolver::class); $this->ipResolver = $this->prophesize(IpApiLocationResolver::class);
@ -84,7 +84,7 @@ class ProcessVisitsCommandTest extends TestCase
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('Processing IP 1.2.3.0', $output); $this->assertStringContainsString('Processing IP 1.2.3.0', $output);
$locateVisits->shouldHaveBeenCalledOnce(); $locateVisits->shouldHaveBeenCalledOnce();
$resolveIpLocation->shouldHaveBeenCalledOnce(); $resolveIpLocation->shouldHaveBeenCalledOnce();
} }
@ -118,7 +118,7 @@ class ProcessVisitsCommandTest extends TestCase
$this->assertInstanceOf(IpCannotBeLocatedException::class, $e); $this->assertInstanceOf(IpCannotBeLocatedException::class, $e);
$this->assertContains($message, $output); $this->assertStringContainsString($message, $output);
$locateVisits->shouldHaveBeenCalledOnce(); $locateVisits->shouldHaveBeenCalledOnce();
$resolveIpLocation->shouldNotHaveBeenCalled(); $resolveIpLocation->shouldNotHaveBeenCalled();
} }
@ -161,7 +161,7 @@ class ProcessVisitsCommandTest extends TestCase
$this->assertInstanceOf(IpCannotBeLocatedException::class, $e); $this->assertInstanceOf(IpCannotBeLocatedException::class, $e);
$this->assertContains('An error occurred while locating IP. Skipped', $output); $this->assertStringContainsString('An error occurred while locating IP. Skipped', $output);
$locateVisits->shouldHaveBeenCalledOnce(); $locateVisits->shouldHaveBeenCalledOnce();
$resolveIpLocation->shouldHaveBeenCalledOnce(); $resolveIpLocation->shouldHaveBeenCalledOnce();
} }
@ -183,7 +183,7 @@ class ProcessVisitsCommandTest extends TestCase
], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE]); ], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains( $this->assertStringContainsString(
sprintf('There is already an instance of the "%s" command', ProcessVisitsCommand::NAME), sprintf('There is already an instance of the "%s" command', ProcessVisitsCommand::NAME),
$output $output
); );

View file

@ -19,7 +19,7 @@ class UpdateDbCommandTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $dbUpdater; private $dbUpdater;
public function setUp() public function setUp(): void
{ {
$this->dbUpdater = $this->prophesize(DbUpdaterInterface::class); $this->dbUpdater = $this->prophesize(DbUpdaterInterface::class);
@ -41,7 +41,7 @@ class UpdateDbCommandTest extends TestCase
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('GeoLite2 database properly updated', $output); $this->assertStringContainsString('GeoLite2 database properly updated', $output);
$download->shouldHaveBeenCalledOnce(); $download->shouldHaveBeenCalledOnce();
} }
@ -55,7 +55,7 @@ class UpdateDbCommandTest extends TestCase
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
$this->assertContains('An error occurred while updating GeoLite2 database', $output); $this->assertStringContainsString('An error occurred while updating GeoLite2 database', $output);
$download->shouldHaveBeenCalledOnce(); $download->shouldHaveBeenCalledOnce();
} }
} }

View file

@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
/** @var ConfigProvider */ /** @var ConfigProvider */
private $configProvider; private $configProvider;
public function setUp() public function setUp(): void
{ {
$this->configProvider = new ConfigProvider(); $this->configProvider = new ConfigProvider();
} }

View file

@ -18,7 +18,7 @@ class ApplicationFactoryTest extends TestCase
/** @var ApplicationFactory */ /** @var ApplicationFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new ApplicationFactory(); $this->factory = new ApplicationFactory();
} }

View file

@ -23,7 +23,7 @@ abstract class DatabaseTestCase extends TestCase
return self::$em; return self::$em;
} }
public function tearDown() public function tearDown(): void
{ {
foreach (static::ENTITIES_TO_EMPTY as $entityClass) { foreach (static::ENTITIES_TO_EMPTY as $entityClass) {
$qb = $this->getEntityManager()->createQueryBuilder(); $qb = $this->getEntityManager()->createQueryBuilder();

View file

@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
/** @var ConfigProvider */ /** @var ConfigProvider */
private $configProvider; private $configProvider;
public function setUp() public function setUp(): void
{ {
$this->configProvider = new ConfigProvider(); $this->configProvider = new ConfigProvider();
} }

View file

@ -19,7 +19,7 @@ class ShlinkTableTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $baseTable; private $baseTable;
public function setUp() public function setUp(): void
{ {
$this->baseTable = $this->prophesize(Table::class); $this->baseTable = $this->prophesize(Table::class);
$this->shlinkTable = new ShlinkTable($this->baseTable->reveal()); $this->shlinkTable = new ShlinkTable($this->baseTable->reveal());

View file

@ -22,12 +22,12 @@ class CacheFactoryTest extends TestCase
/** @var CacheFactory */ /** @var CacheFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new CacheFactory(); $this->factory = new CacheFactory();
} }
public static function tearDownAfterClass() public static function tearDownAfterClass(): void
{ {
putenv('APP_ENV'); putenv('APP_ENV');
} }

View file

@ -14,7 +14,7 @@ class DottedAccessConfigAbstractFactoryTest extends TestCase
/** @var DottedAccessConfigAbstractFactory */ /** @var DottedAccessConfigAbstractFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new DottedAccessConfigAbstractFactory(); $this->factory = new DottedAccessConfigAbstractFactory();
} }

View file

@ -15,7 +15,7 @@ class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
/** @var EmptyResponseImplicitOptionsMiddlewareFactory */ /** @var EmptyResponseImplicitOptionsMiddlewareFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory(); $this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory();
} }

View file

@ -13,7 +13,7 @@ class EntityManagerFactoryTest extends TestCase
/** @var EntityManagerFactory */ /** @var EntityManagerFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new EntityManagerFactory(); $this->factory = new EntityManagerFactory();
} }

View file

@ -14,7 +14,7 @@ class LoggerFactoryTest extends TestCase
/** @var LoggerFactory */ /** @var LoggerFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new LoggerFactory(); $this->factory = new LoggerFactory();
} }

View file

@ -13,7 +13,7 @@ class TranslatorFactoryTest extends TestCase
/** @var TranslatorFactory */ /** @var TranslatorFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new TranslatorFactory(); $this->factory = new TranslatorFactory();
} }

View file

@ -13,7 +13,7 @@ class ImageBuilderFactoryTest extends TestCase
/** @var ImageBuilderFactory */ /** @var ImageBuilderFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new ImageBuilderFactory(); $this->factory = new ImageBuilderFactory();
} }

View file

@ -14,7 +14,7 @@ class ImageFactoryTest extends TestCase
/** @var ImageFactory */ /** @var ImageFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new ImageFactory(); $this->factory = new ImageFactory();
} }

View file

@ -18,7 +18,7 @@ class ChainIpLocationResolverTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $secondInnerResolver; private $secondInnerResolver;
public function setUp() public function setUp(): void
{ {
$this->firstInnerResolver = $this->prophesize(IpLocationResolverInterface::class); $this->firstInnerResolver = $this->prophesize(IpLocationResolverInterface::class);
$this->secondInnerResolver = $this->prophesize(IpLocationResolverInterface::class); $this->secondInnerResolver = $this->prophesize(IpLocationResolverInterface::class);

View file

@ -26,7 +26,7 @@ class EmptyIpLocationResolverTest extends TestCase
/** @var EmptyIpLocationResolver */ /** @var EmptyIpLocationResolver */
private $resolver; private $resolver;
public function setUp() public function setUp(): void
{ {
$this->resolver = new EmptyIpLocationResolver(); $this->resolver = new EmptyIpLocationResolver();
} }

View file

@ -26,7 +26,7 @@ class DbUpdaterTest extends TestCase
/** @var GeoLite2Options */ /** @var GeoLite2Options */
private $options; private $options;
public function setUp() public function setUp(): void
{ {
$this->httpClient = $this->prophesize(ClientInterface::class); $this->httpClient = $this->prophesize(ClientInterface::class);
$this->filesystem = $this->prophesize(Filesystem::class); $this->filesystem = $this->prophesize(Filesystem::class);

View file

@ -19,7 +19,7 @@ class GeoLite2LocationResolverTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $reader; private $reader;
public function setUp() public function setUp(): void
{ {
$this->reader = $this->prophesize(Reader::class); $this->reader = $this->prophesize(Reader::class);
$this->resolver = new GeoLite2LocationResolver($this->reader->reveal()); $this->resolver = new GeoLite2LocationResolver($this->reader->reveal());

View file

@ -8,6 +8,7 @@ use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Shlinkio\Shlink\Common\Exception\WrongIpException;
use Shlinkio\Shlink\Common\IpGeolocation\IpApiLocationResolver; use Shlinkio\Shlink\Common\IpGeolocation\IpApiLocationResolver;
use function json_encode; use function json_encode;
@ -18,7 +19,7 @@ class IpApiLocationResolverTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $client; private $client;
public function setUp() public function setUp(): void
{ {
$this->client = $this->prophesize(Client::class); $this->client = $this->prophesize(Client::class);
$this->ipResolver = new IpApiLocationResolver($this->client->reveal()); $this->ipResolver = new IpApiLocationResolver($this->client->reveal());
@ -52,14 +53,12 @@ class IpApiLocationResolverTest extends TestCase
$this->assertEquals($expected, $this->ipResolver->resolveIpLocation('1.2.3.4')); $this->assertEquals($expected, $this->ipResolver->resolveIpLocation('1.2.3.4'));
} }
/** /** @test */
* @test
* @expectedException \Shlinkio\Shlink\Common\Exception\WrongIpException
*/
public function guzzleExceptionThrowsShlinkException() public function guzzleExceptionThrowsShlinkException()
{ {
$this->client->get('http://ip-api.com/json/1.2.3.4')->willThrow(new TransferException()) $this->client->get('http://ip-api.com/json/1.2.3.4')->willThrow(new TransferException())
->shouldBeCalledOnce(); ->shouldBeCalledOnce();
$this->expectException(WrongIpException::class);
$this->ipResolver->resolveIpLocation('1.2.3.4'); $this->ipResolver->resolveIpLocation('1.2.3.4');
} }
} }

View file

@ -12,7 +12,7 @@ class ExceptionWithNewLineProcessorTest extends TestCase
/** @var ExceptionWithNewLineProcessor */ /** @var ExceptionWithNewLineProcessor */
private $processor; private $processor;
public function setUp() public function setUp(): void
{ {
$this->processor = new ExceptionWithNewLineProcessor(); $this->processor = new ExceptionWithNewLineProcessor();
} }

View file

@ -21,7 +21,7 @@ class CloseDbConnectionMiddlewareTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $em; private $em;
public function setUp() public function setUp(): void
{ {
$this->handler = $this->prophesize(RequestHandlerInterface::class); $this->handler = $this->prophesize(RequestHandlerInterface::class);
$this->em = $this->prophesize(EntityManagerInterface::class); $this->em = $this->prophesize(EntityManagerInterface::class);

View file

@ -13,7 +13,7 @@ class IpAddressMiddlewareFactoryTest extends TestCase
{ {
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new IpAddressMiddlewareFactory(); $this->factory = new IpAddressMiddlewareFactory();
} }

View file

@ -16,7 +16,7 @@ class LocaleMiddlewareTest extends TestCase
/** @var Translator */ /** @var Translator */
private $translator; private $translator;
public function setUp() public function setUp(): void
{ {
$this->translator = Translator::factory(['locale' => 'ru']); $this->translator = Translator::factory(['locale' => 'ru']);
$this->middleware = new LocaleMiddleware($this->translator); $this->middleware = new LocaleMiddleware($this->translator);

View file

@ -15,7 +15,7 @@ class PaginableRepositoryAdapterTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $repo; private $repo;
public function setUp() public function setUp(): void
{ {
$this->repo = $this->prophesize(PaginableRepositoryInterface::class); $this->repo = $this->prophesize(PaginableRepositoryInterface::class);
$this->adapter = new PaginableRepositoryAdapter($this->repo->reveal(), 'search', ['foo', 'bar'], 'order'); $this->adapter = new PaginableRepositoryAdapter($this->repo->reveal(), 'search', ['foo', 'bar'], 'order');

View file

@ -11,7 +11,7 @@ class PixelResponseTest extends TestCase
/** @var PixelResponse */ /** @var PixelResponse */
private $resp; private $resp;
public function setUp() public function setUp(): void
{ {
$this->resp = new PixelResponse(); $this->resp = new PixelResponse();
} }

View file

@ -7,6 +7,7 @@ use mikehaertl\wkhtmlto\Image;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Prophecy\Argument; use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Shlinkio\Shlink\Common\Exception\PreviewGenerationException;
use Shlinkio\Shlink\Common\Image\ImageBuilder; use Shlinkio\Shlink\Common\Image\ImageBuilder;
use Shlinkio\Shlink\Common\Service\PreviewGenerator; use Shlinkio\Shlink\Common\Service\PreviewGenerator;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
@ -23,7 +24,7 @@ class PreviewGeneratorTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $filesystem; private $filesystem;
public function setUp() public function setUp(): void
{ {
$this->image = $this->prophesize(Image::class); $this->image = $this->prophesize(Image::class);
$this->filesystem = $this->prophesize(Filesystem::class); $this->filesystem = $this->prophesize(Filesystem::class);
@ -66,10 +67,7 @@ class PreviewGeneratorTest extends TestCase
$this->assertEquals($expectedPath, $this->generator->generatePreview($url)); $this->assertEquals($expectedPath, $this->generator->generatePreview($url));
} }
/** /** @test */
* @test
* @expectedException \Shlinkio\Shlink\Common\Exception\PreviewGenerationException
*/
public function errorWhileGeneratingPreviewThrowsException() public function errorWhileGeneratingPreviewThrowsException()
{ {
$url = 'http://foo.com'; $url = 'http://foo.com';
@ -82,6 +80,8 @@ class PreviewGeneratorTest extends TestCase
$this->image->saveAs($expectedPath)->shouldBeCalledOnce(); $this->image->saveAs($expectedPath)->shouldBeCalledOnce();
$this->image->getError()->willReturn('Error!!')->shouldBeCalledOnce(); $this->image->getError()->willReturn('Error!!')->shouldBeCalledOnce();
$this->expectException(PreviewGenerationException::class);
$this->generator->generatePreview($url); $this->generator->generatePreview($url);
} }
} }

View file

@ -14,7 +14,7 @@ class TranslatorExtensionTest extends TestCase
/** @var TranslatorExtension */ /** @var TranslatorExtension */
private $extension; private $extension;
public function setUp() public function setUp(): void
{ {
$this->extension = new TranslatorExtension($this->prophesize(Translator::class)->reveal()); $this->extension = new TranslatorExtension($this->prophesize(Translator::class)->reveal());
} }

View file

@ -19,7 +19,7 @@ class ChronosDateTimeTypeTest extends TestCase
/** @var ChronosDateTimeType */ /** @var ChronosDateTimeType */
private $type; private $type;
public function setUp() public function setUp(): void
{ {
if (! Type::hasType(ChronosDateTimeType::CHRONOS_DATETIME)) { if (! Type::hasType(ChronosDateTimeType::CHRONOS_DATETIME)) {
Type::addType(ChronosDateTimeType::CHRONOS_DATETIME, ChronosDateTimeType::class); Type::addType(ChronosDateTimeType::CHRONOS_DATETIME, ChronosDateTimeType::class);

View file

@ -25,7 +25,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
/** @var ShortUrlRepository */ /** @var ShortUrlRepository */
private $repo; private $repo;
public function setUp() public function setUp(): void
{ {
$this->repo = $this->getEntityManager()->getRepository(ShortUrl::class); $this->repo = $this->getEntityManager()->getRepository(ShortUrl::class);
} }

View file

@ -16,7 +16,7 @@ class TagRepositoryTest extends DatabaseTestCase
/** @var TagRepository */ /** @var TagRepository */
private $repo; private $repo;
protected function setUp() protected function setUp(): void
{ {
$this->repo = $this->getEntityManager()->getRepository(Tag::class); $this->repo = $this->getEntityManager()->getRepository(Tag::class);
} }

View file

@ -24,7 +24,7 @@ class VisitRepositoryTest extends DatabaseTestCase
/** @var VisitRepository */ /** @var VisitRepository */
private $repo; private $repo;
protected function setUp() protected function setUp(): void
{ {
$this->repo = $this->getEntityManager()->getRepository(Visit::class); $this->repo = $this->getEntityManager()->getRepository(Visit::class);
} }

View file

@ -25,7 +25,7 @@ class PixelActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $visitTracker; private $visitTracker;
public function setUp() public function setUp(): void
{ {
$this->urlShortener = $this->prophesize(UrlShortener::class); $this->urlShortener = $this->prophesize(UrlShortener::class);
$this->visitTracker = $this->prophesize(VisitsTracker::class); $this->visitTracker = $this->prophesize(VisitsTracker::class);

View file

@ -30,7 +30,7 @@ class PreviewActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $urlShortener; private $urlShortener;
public function setUp() public function setUp(): void
{ {
$this->previewGenerator = $this->prophesize(PreviewGenerator::class); $this->previewGenerator = $this->prophesize(PreviewGenerator::class);
$this->urlShortener = $this->prophesize(UrlShortener::class); $this->urlShortener = $this->prophesize(UrlShortener::class);

View file

@ -25,7 +25,7 @@ class QrCodeActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $urlShortener; private $urlShortener;
public function setUp() public function setUp(): void
{ {
$router = $this->prophesize(RouterInterface::class); $router = $this->prophesize(RouterInterface::class);
$router->generateUri(Argument::cetera())->willReturn('/foo/bar'); $router->generateUri(Argument::cetera())->willReturn('/foo/bar');

View file

@ -28,7 +28,7 @@ class RedirectActionTest extends TestCase
/** @var Options\NotFoundShortUrlOptions */ /** @var Options\NotFoundShortUrlOptions */
private $notFoundOptions; private $notFoundOptions;
public function setUp() public function setUp(): void
{ {
$this->urlShortener = $this->prophesize(UrlShortener::class); $this->urlShortener = $this->prophesize(UrlShortener::class);
$this->visitTracker = $this->prophesize(VisitsTracker::class); $this->visitTracker = $this->prophesize(VisitsTracker::class);

View file

@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
/** @var ConfigProvider */ /** @var ConfigProvider */
private $configProvider; private $configProvider;
public function setUp() public function setUp(): void
{ {
$this->configProvider = new ConfigProvider(); $this->configProvider = new ConfigProvider();
} }

View file

@ -20,7 +20,7 @@ class QrCodeCacheMiddlewareTest extends TestCase
/** @var Cache */ /** @var Cache */
private $cache; private $cache;
public function setUp() public function setUp(): void
{ {
$this->cache = new ArrayCache(); $this->cache = new ArrayCache();
$this->middleware = new QrCodeCacheMiddleware($this->cache); $this->middleware = new QrCodeCacheMiddleware($this->cache);

View file

@ -19,7 +19,7 @@ class NotFoundHandlerTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $renderer; private $renderer;
public function setUp() public function setUp(): void
{ {
$this->renderer = $this->prophesize(TemplateRendererInterface::class); $this->renderer = $this->prophesize(TemplateRendererInterface::class);
$this->delegate = new NotFoundHandler($this->renderer->reveal()); $this->delegate = new NotFoundHandler($this->renderer->reveal());

View file

@ -25,7 +25,7 @@ class DeleteShortUrlServiceTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $em; private $em;
public function setUp() public function setUp(): void
{ {
$shortUrl = (new ShortUrl(''))->setShortCode('abc123') $shortUrl = (new ShortUrl(''))->setShortCode('abc123')
->setVisits(new ArrayCollection(map(range(0, 10), function () { ->setVisits(new ArrayCollection(map(range(0, 10), function () {

View file

@ -24,7 +24,7 @@ class ShortUrlServiceTest extends TestCase
/** @var ObjectProphecy|EntityManagerInterface */ /** @var ObjectProphecy|EntityManagerInterface */
private $em; private $em;
public function setUp() public function setUp(): void
{ {
$this->em = $this->prophesize(EntityManagerInterface::class); $this->em = $this->prophesize(EntityManagerInterface::class);
$this->em->persist(Argument::any())->willReturn(null); $this->em->persist(Argument::any())->willReturn(null);

View file

@ -21,7 +21,7 @@ class TagServiceTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $em; private $em;
public function setUp() public function setUp(): void
{ {
$this->em = $this->prophesize(EntityManagerInterface::class); $this->em = $this->prophesize(EntityManagerInterface::class);
$this->service = new TagService($this->em->reveal()); $this->service = new TagService($this->em->reveal());

View file

@ -17,7 +17,10 @@ use Prophecy\Prophecy\MethodProphecy;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Entity\Tag; use Shlinkio\Shlink\Core\Entity\Tag;
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
use Shlinkio\Shlink\Core\Exception\RuntimeException;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions; use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
@ -80,10 +83,7 @@ class UrlShortenerTest extends TestCase
$this->assertEquals('0Q1Y', $shortUrl->getShortCode()); $this->assertEquals('0Q1Y', $shortUrl->getShortCode());
} }
/** /** @test */
* @test
* @expectedException \Shlinkio\Shlink\Core\Exception\RuntimeException
*/
public function exceptionIsThrownWhenOrmThrowsException(): void public function exceptionIsThrownWhenOrmThrowsException(): void
{ {
$conn = $this->prophesize(Connection::class); $conn = $this->prophesize(Connection::class);
@ -93,6 +93,8 @@ class UrlShortenerTest extends TestCase
$this->em->close()->shouldBeCalledOnce(); $this->em->close()->shouldBeCalledOnce();
$this->em->flush()->willThrow(new ORMException()); $this->em->flush()->willThrow(new ORMException());
$this->expectException(RuntimeException::class);
$this->urlShortener->urlToShortCode( $this->urlShortener->urlToShortCode(
new Uri('http://foobar.com/12345/hello?foo=bar'), new Uri('http://foobar.com/12345/hello?foo=bar'),
[], [],
@ -100,10 +102,7 @@ class UrlShortenerTest extends TestCase
); );
} }
/** /** @test */
* @test
* @expectedException \Shlinkio\Shlink\Core\Exception\InvalidUrlException
*/
public function exceptionIsThrownWhenUrlDoesNotExist(): void public function exceptionIsThrownWhenUrlDoesNotExist(): void
{ {
$this->setUrlShortener(true); $this->setUrlShortener(true);
@ -111,6 +110,8 @@ class UrlShortenerTest extends TestCase
$this->httpClient->request(Argument::cetera())->willThrow( $this->httpClient->request(Argument::cetera())->willThrow(
new ClientException('', $this->prophesize(Request::class)->reveal()) new ClientException('', $this->prophesize(Request::class)->reveal())
); );
$this->expectException(InvalidUrlException::class);
$this->urlShortener->urlToShortCode( $this->urlShortener->urlToShortCode(
new Uri('http://foobar.com/12345/hello?foo=bar'), new Uri('http://foobar.com/12345/hello?foo=bar'),
[], [],
@ -227,12 +228,10 @@ class UrlShortenerTest extends TestCase
$this->assertSame($shortUrl, $url); $this->assertSame($shortUrl, $url);
} }
/** /** @test */
* @test
* @expectedException \Shlinkio\Shlink\Core\Exception\InvalidShortCodeException
*/
public function invalidCharSetThrowsException(): void public function invalidCharSetThrowsException(): void
{ {
$this->expectException(InvalidShortCodeException::class);
$this->urlShortener->shortCodeToUrl('&/('); $this->urlShortener->shortCodeToUrl('&/(');
} }
} }

View file

@ -25,7 +25,7 @@ class VisitServiceTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $em; private $em;
public function setUp() public function setUp(): void
{ {
$this->em = $this->prophesize(EntityManager::class); $this->em = $this->prophesize(EntityManager::class);
$this->visitService = new VisitService($this->em->reveal()); $this->visitService = new VisitService($this->em->reveal());

View file

@ -25,7 +25,7 @@ class VisitsTrackerTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $em; private $em;
public function setUp() public function setUp(): void
{ {
$this->em = $this->prophesize(EntityManager::class); $this->em = $this->prophesize(EntityManager::class);
$this->visitsTracker = new VisitsTracker($this->em->reveal()); $this->visitsTracker = new VisitsTracker($this->em->reveal());

View file

@ -22,7 +22,7 @@ class AuthenticateActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $jwtService; private $jwtService;
public function setUp() public function setUp(): void
{ {
$this->apiKeyService = $this->prophesize(ApiKeyService::class); $this->apiKeyService = $this->prophesize(ApiKeyService::class);
$this->jwtService = $this->prophesize(JWTService::class); $this->jwtService = $this->prophesize(JWTService::class);

View file

@ -16,7 +16,7 @@ class HealthActionFactoryTest extends TestCase
/** @var Action\HealthActionFactory */ /** @var Action\HealthActionFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new Action\HealthActionFactory(); $this->factory = new Action\HealthActionFactory();
} }

View file

@ -19,7 +19,7 @@ class HealthActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $conn; private $conn;
public function setUp() public function setUp(): void
{ {
$this->conn = $this->prophesize(Connection::class); $this->conn = $this->prophesize(Connection::class);
$this->action = new HealthAction($this->conn->reveal(), new AppOptions(['version' => '1.2.3'])); $this->action = new HealthAction($this->conn->reveal(), new AppOptions(['version' => '1.2.3']));

View file

@ -25,7 +25,7 @@ class CreateShortUrlActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $urlShortener; private $urlShortener;
public function setUp() public function setUp(): void
{ {
$this->urlShortener = $this->prophesize(UrlShortener::class); $this->urlShortener = $this->prophesize(UrlShortener::class);
$this->action = new CreateShortUrlAction($this->urlShortener->reveal(), [ $this->action = new CreateShortUrlAction($this->urlShortener->reveal(), [
@ -97,7 +97,7 @@ class CreateShortUrlActionTest extends TestCase
]); ]);
$response = $this->action->handle($request); $response = $this->action->handle($request);
$this->assertEquals(400, $response->getStatusCode()); $this->assertEquals(400, $response->getStatusCode());
$this->assertContains(RestUtils::INVALID_SLUG_ERROR, (string) $response->getBody()); $this->assertStringContainsString(RestUtils::INVALID_SLUG_ERROR, (string) $response->getBody());
} }
/** /**

View file

@ -21,7 +21,7 @@ class DeleteShortUrlActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $service; private $service;
public function setUp() public function setUp(): void
{ {
$this->service = $this->prophesize(DeleteShortUrlServiceInterface::class); $this->service = $this->prophesize(DeleteShortUrlServiceInterface::class);
$this->action = new DeleteShortUrlAction($this->service->reveal()); $this->action = new DeleteShortUrlAction($this->service->reveal());

View file

@ -21,7 +21,7 @@ class EditShortUrlActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $shortUrlService; private $shortUrlService;
public function setUp() public function setUp(): void
{ {
$this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class); $this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class);
$this->action = new EditShortUrlAction($this->shortUrlService->reveal()); $this->action = new EditShortUrlAction($this->shortUrlService->reveal());

View file

@ -18,7 +18,7 @@ class EditShortUrlTagsActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $shortUrlService; private $shortUrlService;
public function setUp() public function setUp(): void
{ {
$this->shortUrlService = $this->prophesize(ShortUrlService::class); $this->shortUrlService = $this->prophesize(ShortUrlService::class);
$this->action = new EditShortUrlTagsAction($this->shortUrlService->reveal()); $this->action = new EditShortUrlTagsAction($this->shortUrlService->reveal());

View file

@ -19,7 +19,7 @@ class ListShortUrlsActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $service; private $service;
public function setUp() public function setUp(): void
{ {
$this->service = $this->prophesize(ShortUrlService::class); $this->service = $this->prophesize(ShortUrlService::class);
$this->action = new ListShortUrlsAction($this->service->reveal(), [ $this->action = new ListShortUrlsAction($this->service->reveal(), [

View file

@ -22,7 +22,7 @@ class ResolveShortUrlActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $urlShortener; private $urlShortener;
public function setUp() public function setUp(): void
{ {
$this->urlShortener = $this->prophesize(UrlShortener::class); $this->urlShortener = $this->prophesize(UrlShortener::class);
$this->action = new ResolveShortUrlAction($this->urlShortener->reveal(), []); $this->action = new ResolveShortUrlAction($this->urlShortener->reveal(), []);

View file

@ -25,7 +25,7 @@ class SingleStepCreateShortUrlActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $apiKeyService; private $apiKeyService;
public function setUp() public function setUp(): void
{ {
$this->urlShortener = $this->prophesize(UrlShortenerInterface::class); $this->urlShortener = $this->prophesize(UrlShortenerInterface::class);
$this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class); $this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class);

View file

@ -18,7 +18,7 @@ class CreateTagsActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
$this->action = new CreateTagsAction($this->tagService->reveal()); $this->action = new CreateTagsAction($this->tagService->reveal());

View file

@ -17,7 +17,7 @@ class DeleteTagsActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
$this->action = new DeleteTagsAction($this->tagService->reveal()); $this->action = new DeleteTagsAction($this->tagService->reveal());

View file

@ -19,7 +19,7 @@ class ListTagsActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
$this->action = new ListTagsAction($this->tagService->reveal()); $this->action = new ListTagsAction($this->tagService->reveal());

View file

@ -19,7 +19,7 @@ class UpdateTagActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $tagService; private $tagService;
public function setUp() public function setUp(): void
{ {
$this->tagService = $this->prophesize(TagServiceInterface::class); $this->tagService = $this->prophesize(TagServiceInterface::class);
$this->action = new UpdateTagAction($this->tagService->reveal()); $this->action = new UpdateTagAction($this->tagService->reveal());

View file

@ -23,7 +23,7 @@ class GetVisitsActionTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $visitsTracker; private $visitsTracker;
public function setUp() public function setUp(): void
{ {
$this->visitsTracker = $this->prophesize(VisitsTracker::class); $this->visitsTracker = $this->prophesize(VisitsTracker::class);
$this->action = new GetVisitsAction($this->visitsTracker->reveal()); $this->action = new GetVisitsAction($this->visitsTracker->reveal());

View file

@ -13,7 +13,7 @@ class AuthenticationPluginManagerFactoryTest extends TestCase
/** @var AuthenticationPluginManagerFactory */ /** @var AuthenticationPluginManagerFactory */
private $factory; private $factory;
public function setUp() public function setUp(): void
{ {
$this->factory = new AuthenticationPluginManagerFactory(); $this->factory = new AuthenticationPluginManagerFactory();
} }

View file

@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Options\AppOptions; use Shlinkio\Shlink\Core\Options\AppOptions;
use Shlinkio\Shlink\Rest\Authentication\JWTService; use Shlinkio\Shlink\Rest\Authentication\JWTService;
use Shlinkio\Shlink\Rest\Entity\ApiKey; use Shlinkio\Shlink\Rest\Entity\ApiKey;
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
use function time; use function time;
class JWTServiceTest extends TestCase class JWTServiceTest extends TestCase
@ -15,7 +16,7 @@ class JWTServiceTest extends TestCase
/** @var JWTService */ /** @var JWTService */
private $service; private $service;
public function setUp() public function setUp(): void
{ {
$this->service = new JWTService(new AppOptions([ $this->service = new JWTService(new AppOptions([
'name' => 'ShlinkTest', 'name' => 'ShlinkTest',
@ -83,12 +84,10 @@ class JWTServiceTest extends TestCase
$this->assertEquals($originalPayload, $this->service->getPayload($token)); $this->assertEquals($originalPayload, $this->service->getPayload($token));
} }
/** /** @test */
* @test
* @expectedException \Shlinkio\Shlink\Rest\Exception\AuthenticationException
*/
public function getPayloadThrowsExceptionWithIncorrectTokens() public function getPayloadThrowsExceptionWithIncorrectTokens()
{ {
$this->expectException(AuthenticationException::class);
$this->service->getPayload('invalidToken'); $this->service->getPayload('invalidToken');
} }
} }

View file

@ -19,7 +19,7 @@ class ApiKeyHeaderPluginTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $apiKeyService; private $apiKeyService;
public function setUp() public function setUp(): void
{ {
$this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class); $this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class);
$this->plugin = new ApiKeyHeaderPlugin($this->apiKeyService->reveal()); $this->plugin = new ApiKeyHeaderPlugin($this->apiKeyService->reveal());

View file

@ -19,7 +19,7 @@ class AuthorizationHeaderPluginTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $jwtService; private $jwtService;
public function setUp() public function setUp(): void
{ {
$this->jwtService = $this->prophesize(JWTServiceInterface::class); $this->jwtService = $this->prophesize(JWTServiceInterface::class);
$this->plugin = new AuthorizationHeaderPlugin($this->jwtService->reveal()); $this->plugin = new AuthorizationHeaderPlugin($this->jwtService->reveal());

View file

@ -22,7 +22,7 @@ class RequestToAuthPluginTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $pluginManager; private $pluginManager;
public function setUp() public function setUp(): void
{ {
$this->pluginManager = $this->prophesize(AuthenticationPluginManagerInterface::class); $this->pluginManager = $this->prophesize(AuthenticationPluginManagerInterface::class);
$this->requestToPlugin = new RequestToHttpAuthPlugin($this->pluginManager->reveal()); $this->requestToPlugin = new RequestToHttpAuthPlugin($this->pluginManager->reveal());

View file

@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
/** @var ConfigProvider */ /** @var ConfigProvider */
private $configProvider; private $configProvider;
public function setUp() public function setUp(): void
{ {
$this->configProvider = new ConfigProvider(); $this->configProvider = new ConfigProvider();
} }

View file

@ -13,7 +13,7 @@ class JsonErrorResponseGeneratorTest extends TestCase
/** @var JsonErrorResponseGenerator */ /** @var JsonErrorResponseGenerator */
private $errorHandler; private $errorHandler;
public function setUp() public function setUp(): void
{ {
$this->errorHandler = new JsonErrorResponseGenerator(); $this->errorHandler = new JsonErrorResponseGenerator();
} }

View file

@ -39,7 +39,7 @@ class AuthenticationMiddlewareTest extends TestCase
/** @var callable */ /** @var callable */
private $dummyMiddleware; private $dummyMiddleware;
public function setUp() public function setUp(): void
{ {
$this->requestToPlugin = $this->prophesize(RequestToHttpAuthPluginInterface::class); $this->requestToPlugin = $this->prophesize(RequestToHttpAuthPluginInterface::class);
$this->middleware = new AuthenticationMiddleware($this->requestToPlugin->reveal(), [AuthenticateAction::class]); $this->middleware = new AuthenticationMiddleware($this->requestToPlugin->reveal(), [AuthenticateAction::class]);

View file

@ -19,7 +19,7 @@ class BodyParserMiddlewareTest extends TestCase
/** @var BodyParserMiddleware */ /** @var BodyParserMiddleware */
private $middleware; private $middleware;
public function setUp() public function setUp(): void
{ {
$this->middleware = new BodyParserMiddleware(); $this->middleware = new BodyParserMiddleware();
} }

View file

@ -18,7 +18,7 @@ class CrossDomainMiddlewareTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $delegate; private $delegate;
public function setUp() public function setUp(): void
{ {
$this->middleware = new CrossDomainMiddleware(); $this->middleware = new CrossDomainMiddleware();
$this->delegate = $this->prophesize(RequestHandlerInterface::class); $this->delegate = $this->prophesize(RequestHandlerInterface::class);

View file

@ -19,7 +19,7 @@ class PathVersionMiddlewareTest extends TestCase
/** @var PathVersionMiddleware */ /** @var PathVersionMiddleware */
private $middleware; private $middleware;
public function setUp() public function setUp(): void
{ {
$this->middleware = new PathVersionMiddleware(); $this->middleware = new PathVersionMiddleware();
} }

View file

@ -19,7 +19,7 @@ class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
/** @var RequestHandlerInterface */ /** @var RequestHandlerInterface */
private $requestHandler; private $requestHandler;
public function setUp() public function setUp(): void
{ {
$this->middleware = new CreateShortUrlContentNegotiationMiddleware(); $this->middleware = new CreateShortUrlContentNegotiationMiddleware();
$this->requestHandler = $this->prophesize(RequestHandlerInterface::class); $this->requestHandler = $this->prophesize(RequestHandlerInterface::class);

View file

@ -18,7 +18,7 @@ class ShortCodePathMiddlewareTest extends TestCase
private $middleware; private $middleware;
private $requestHandler; private $requestHandler;
public function setUp() public function setUp(): void
{ {
$this->middleware = new ShortCodePathMiddleware(); $this->middleware = new ShortCodePathMiddleware();
$this->requestHandler = $this->prophesize(RequestHandlerInterface::class); $this->requestHandler = $this->prophesize(RequestHandlerInterface::class);
@ -37,8 +37,8 @@ class ShortCodePathMiddlewareTest extends TestCase
$withUri = $request->withUri(Argument::that(function (UriInterface $uri) { $withUri = $request->withUri(Argument::that(function (UriInterface $uri) {
$path = $uri->getPath(); $path = $uri->getPath();
Assert::assertContains('/short-urls', $path); Assert::assertStringContainsString('/short-urls', $path);
Assert::assertNotContains('/short-codes', $path); Assert::assertStringNotContainsString('/short-codes', $path);
return $uri; return $uri;
}))->willReturn($request->reveal()); }))->willReturn($request->reveal());

View file

@ -9,6 +9,7 @@ use Doctrine\ORM\EntityRepository;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Prophecy\Argument; use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
use Shlinkio\Shlink\Rest\Entity\ApiKey; use Shlinkio\Shlink\Rest\Entity\ApiKey;
use Shlinkio\Shlink\Rest\Service\ApiKeyService; use Shlinkio\Shlink\Rest\Service\ApiKeyService;
@ -19,7 +20,7 @@ class ApiKeyServiceTest extends TestCase
/** @var ObjectProphecy */ /** @var ObjectProphecy */
private $em; private $em;
public function setUp() public function setUp(): void
{ {
$this->em = $this->prophesize(EntityManager::class); $this->em = $this->prophesize(EntityManager::class);
$this->service = new ApiKeyService($this->em->reveal()); $this->service = new ApiKeyService($this->em->reveal());
@ -105,10 +106,7 @@ class ApiKeyServiceTest extends TestCase
$this->assertTrue($this->service->check('12345')); $this->assertTrue($this->service->check('12345'));
} }
/** /** @test */
* @test
* @expectedException \Shlinkio\Shlink\Common\Exception\InvalidArgumentException
*/
public function disableThrowsExceptionWhenNoTokenIsFound() public function disableThrowsExceptionWhenNoTokenIsFound()
{ {
$repo = $this->prophesize(EntityRepository::class); $repo = $this->prophesize(EntityRepository::class);
@ -116,6 +114,7 @@ class ApiKeyServiceTest extends TestCase
->shouldBeCalledOnce(); ->shouldBeCalledOnce();
$this->em->getRepository(ApiKey::class)->willReturn($repo->reveal()); $this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
$this->expectException(InvalidArgumentException::class);
$this->service->disable('12345'); $this->service->disable('12345');
} }