mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 16:26:37 +03:00
Merge pull request #353 from acelaya/feature/testing-tools
Updated testing tools
This commit is contained in:
commit
25927a296d
91 changed files with 192 additions and 192 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ data/shlink-tests.db
|
|||
data/GeoLite2-City.mmdb
|
||||
docs/swagger-ui*
|
||||
docker-compose.override.yml
|
||||
.phpunit.result.cache
|
||||
|
|
|
@ -10,5 +10,5 @@ echo 'Starting server...'
|
|||
vendor/bin/zend-expressive-swoole start -d
|
||||
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
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
"filp/whoops": "^2.0",
|
||||
"infection/infection": "^0.11.0",
|
||||
"phpstan/phpstan": "^0.10.0",
|
||||
"phpunit/phpcov": "^5.0",
|
||||
"phpunit/phpunit": "^7.3",
|
||||
"phpunit/phpcov": "^6.0@dev || ^5.0",
|
||||
"phpunit/phpunit": "^8.0 || ^7.5",
|
||||
"roave/security-advisories": "dev-master",
|
||||
"shlinkio/php-coding-standard": "~1.0.0",
|
||||
"symfony/dotenv": "^4.2",
|
||||
|
@ -112,9 +112,9 @@
|
|||
"@test:db",
|
||||
"@test:api"
|
||||
],
|
||||
"test:unit": "phpdbg -qrr vendor/bin/phpunit --order-by=random --coverage-php build/coverage-unit.cov",
|
||||
"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:db": "APP_ENV=test phpdbg -qrr vendor/bin/phpunit --order-by=random -c phpunit-db.xml --coverage-php build/coverage-db.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 --testdox",
|
||||
"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:pretty": [
|
||||
|
@ -147,7 +147,8 @@
|
|||
"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: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": {
|
||||
"sort-packages": true
|
||||
|
|
|
@ -18,7 +18,7 @@ class DisableKeyCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
|
||||
$command = new DisableKeyCommand($this->apiKeyService->reveal());
|
||||
|
@ -41,7 +41,7 @@ class DisableKeyCommandTest extends TestCase
|
|||
]);
|
||||
$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();
|
||||
|
||||
$this->assertContains('API key "abcd1234" does not exist.', $output);
|
||||
$this->assertStringContainsString('API key "abcd1234" does not exist.', $output);
|
||||
$disable->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class GenerateKeyCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
|
||||
$command = new GenerateKeyCommand($this->apiKeyService->reveal());
|
||||
|
@ -41,7 +41,7 @@ class GenerateKeyCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('Generated API key: ', $output);
|
||||
$this->assertStringContainsString('Generated API key: ', $output);
|
||||
$create->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class ListKeysCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
|
||||
$command = new ListKeysCommand($this->apiKeyService->reveal());
|
||||
|
@ -27,10 +27,8 @@ class ListKeysCommandTest extends TestCase
|
|||
$this->commandTester = new CommandTester($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function everythingIsListedIfEnabledOnlyIsNotProvided()
|
||||
/** @test */
|
||||
public function everythingIsListedIfEnabledOnlyIsNotProvided(): void
|
||||
{
|
||||
$this->apiKeyService->listKeys(false)->willReturn([
|
||||
new ApiKey(),
|
||||
|
@ -43,17 +41,15 @@ class ListKeysCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('Key', $output);
|
||||
$this->assertContains('Is enabled', $output);
|
||||
$this->assertContains(' +++ ', $output);
|
||||
$this->assertNotContains(' --- ', $output);
|
||||
$this->assertContains('Expiration date', $output);
|
||||
$this->assertStringContainsString('Key', $output);
|
||||
$this->assertStringContainsString('Is enabled', $output);
|
||||
$this->assertStringContainsString(' +++ ', $output);
|
||||
$this->assertStringNotContainsString(' --- ', $output);
|
||||
$this->assertStringContainsString('Expiration date', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function onlyEnabledKeysAreListedIfEnabledOnlyIsProvided()
|
||||
/** @test */
|
||||
public function onlyEnabledKeysAreListedIfEnabledOnlyIsProvided(): void
|
||||
{
|
||||
$this->apiKeyService->listKeys(true)->willReturn([
|
||||
(new ApiKey())->disable(),
|
||||
|
@ -66,10 +62,10 @@ class ListKeysCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('Key', $output);
|
||||
$this->assertNotContains('Is enabled', $output);
|
||||
$this->assertNotContains(' +++ ', $output);
|
||||
$this->assertNotContains(' --- ', $output);
|
||||
$this->assertContains('Expiration date', $output);
|
||||
$this->assertStringContainsString('Key', $output);
|
||||
$this->assertStringNotContainsString('Is enabled', $output);
|
||||
$this->assertStringNotContainsString(' +++ ', $output);
|
||||
$this->assertStringNotContainsString(' --- ', $output);
|
||||
$this->assertStringContainsString('Expiration date', $output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class GenerateCharsetCommandTest extends TestCase
|
|||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$command = new GenerateCharsetCommand();
|
||||
$app = new Application();
|
||||
|
@ -38,7 +38,7 @@ class GenerateCharsetCommandTest extends TestCase
|
|||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
// 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)
|
||||
|
|
|
@ -21,7 +21,7 @@ class DeleteShortCodeCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $service;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->service = $this->prophesize(DeleteShortUrlServiceInterface::class);
|
||||
|
||||
|
@ -44,7 +44,10 @@ class DeleteShortCodeCommandTest extends TestCase
|
|||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
$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();
|
||||
}
|
||||
|
||||
|
@ -61,7 +64,7 @@ class DeleteShortCodeCommandTest extends TestCase
|
|||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
$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();
|
||||
}
|
||||
|
||||
|
@ -85,11 +88,14 @@ class DeleteShortCodeCommandTest extends TestCase
|
|||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
$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.',
|
||||
$shortCode
|
||||
), $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);
|
||||
}
|
||||
|
||||
|
@ -107,11 +113,11 @@ class DeleteShortCodeCommandTest extends TestCase
|
|||
$this->commandTester->execute(['shortCode' => $shortCode]);
|
||||
$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.',
|
||||
$shortCode
|
||||
), $output);
|
||||
$this->assertContains('Short URL was not deleted.', $output);
|
||||
$this->assertStringContainsString('Short URL was not deleted.', $output);
|
||||
$deleteByShortCode->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class GeneratePreviewCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $shortUrlService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->previewGenerator = $this->prophesize(PreviewGenerator::class);
|
||||
$this->shortUrlService = $this->prophesize(ShortUrlService::class);
|
||||
|
@ -60,10 +60,10 @@ class GeneratePreviewCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('Processing URL http://foo.com', $output);
|
||||
$this->assertContains('Processing URL https://bar.com', $output);
|
||||
$this->assertContains('Processing URL http://baz.com/something', $output);
|
||||
$this->assertContains('Finished processing all URLs', $output);
|
||||
$this->assertStringContainsString('Processing URL http://foo.com', $output);
|
||||
$this->assertStringContainsString('Processing URL https://bar.com', $output);
|
||||
$this->assertStringContainsString('Processing URL http://baz.com/something', $output);
|
||||
$this->assertStringContainsString('Finished processing all URLs', $output);
|
||||
$generatePreview1->shouldHaveBeenCalledOnce();
|
||||
$generatePreview2->shouldHaveBeenCalledOnce();
|
||||
$generatePreview3->shouldHaveBeenCalledOnce();
|
||||
|
|
|
@ -22,7 +22,7 @@ class GenerateShortUrlCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->prophesize(UrlShortener::class);
|
||||
$command = new GenerateShortUrlCommand($this->urlShortener->reveal(), [
|
||||
|
@ -50,7 +50,7 @@ class GenerateShortUrlCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('http://foo.com/abc123', $output);
|
||||
$this->assertStringContainsString('http://foo.com/abc123', $output);
|
||||
$urlToShortCode->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class GenerateShortUrlCommandTest extends TestCase
|
|||
'longUrl' => 'http://domain.com/invalid',
|
||||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'Provided URL "http://domain.com/invalid" is invalid.',
|
||||
$output
|
||||
);
|
||||
|
@ -94,7 +94,7 @@ class GenerateShortUrlCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('http://foo.com/abc123', $output);
|
||||
$this->assertStringContainsString('http://foo.com/abc123', $output);
|
||||
$urlToShortCode->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class GetVisitsCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $visitsTracker;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->visitsTracker = $this->prophesize(VisitsTrackerInterface::class);
|
||||
$command = new GetVisitsCommand($this->visitsTracker->reveal());
|
||||
|
@ -94,8 +94,8 @@ class GetVisitsCommandTest extends TestCase
|
|||
'shortCode' => $shortCode,
|
||||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
$this->assertContains('foo', $output);
|
||||
$this->assertContains('Spain', $output);
|
||||
$this->assertContains('bar', $output);
|
||||
$this->assertStringContainsString('foo', $output);
|
||||
$this->assertStringContainsString('Spain', $output);
|
||||
$this->assertStringContainsString('bar', $output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $shortUrlService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class);
|
||||
$app = new Application();
|
||||
|
@ -61,9 +61,9 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
$this->commandTester->execute(['command' => 'shortcode:list']);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('Continue with page 2?', $output);
|
||||
$this->assertContains('Continue with page 3?', $output);
|
||||
$this->assertContains('Continue with page 4?', $output);
|
||||
$this->assertStringContainsString('Continue with page 2?', $output);
|
||||
$this->assertStringContainsString('Continue with page 3?', $output);
|
||||
$this->assertStringContainsString('Continue with page 4?', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,13 +84,13 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
$this->commandTester->execute(['command' => 'shortcode:list']);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('url_1', $output);
|
||||
$this->assertContains('url_9', $output);
|
||||
$this->assertNotContains('url_10', $output);
|
||||
$this->assertNotContains('url_20', $output);
|
||||
$this->assertNotContains('url_30', $output);
|
||||
$this->assertContains('Continue with page 2?', $output);
|
||||
$this->assertNotContains('Continue with page 3?', $output);
|
||||
$this->assertStringContainsString('url_1', $output);
|
||||
$this->assertStringContainsString('url_9', $output);
|
||||
$this->assertStringNotContainsString('url_10', $output);
|
||||
$this->assertStringNotContainsString('url_20', $output);
|
||||
$this->assertStringNotContainsString('url_30', $output);
|
||||
$this->assertStringContainsString('Continue with page 2?', $output);
|
||||
$this->assertStringNotContainsString('Continue with page 3?', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,6 +123,6 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
'--showTags' => true,
|
||||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
$this->assertContains('Tags', $output);
|
||||
$this->assertStringContainsString('Tags', $output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class ResolveUrlCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->prophesize(UrlShortener::class);
|
||||
$command = new ResolveUrlCommand($this->urlShortener->reveal());
|
||||
|
@ -64,7 +64,7 @@ class ResolveUrlCommandTest extends TestCase
|
|||
'shortCode' => $shortCode,
|
||||
]);
|
||||
$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,
|
||||
]);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class CreateTagCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
|
||||
|
@ -38,7 +38,7 @@ class CreateTagCommandTest extends TestCase
|
|||
$this->commandTester->execute([]);
|
||||
|
||||
$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();
|
||||
|
||||
$this->assertContains('Tags properly created', $output);
|
||||
$this->assertStringContainsString('Tags properly created', $output);
|
||||
$createTags->shouldHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class DeleteTagsCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
|
||||
|
@ -39,7 +39,7 @@ class DeleteTagsCommandTest extends TestCase
|
|||
$this->commandTester->execute([]);
|
||||
|
||||
$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();
|
||||
|
||||
$this->assertContains('Tags properly deleted', $output);
|
||||
$this->assertStringContainsString('Tags properly deleted', $output);
|
||||
$deleteTags->shouldHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class ListTagsCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
|
||||
|
@ -43,7 +43,7 @@ class ListTagsCommandTest extends TestCase
|
|||
$this->commandTester->execute([]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('No tags yet', $output);
|
||||
$this->assertStringContainsString('No tags yet', $output);
|
||||
$listTags->shouldHaveBeenCalled();
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,8 @@ class ListTagsCommandTest extends TestCase
|
|||
$this->commandTester->execute([]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('foo', $output);
|
||||
$this->assertContains('bar', $output);
|
||||
$this->assertStringContainsString('foo', $output);
|
||||
$this->assertStringContainsString('bar', $output);
|
||||
$listTags->shouldHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class RenameTagCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
|
||||
|
@ -49,7 +49,7 @@ class RenameTagCommandTest extends TestCase
|
|||
]);
|
||||
$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();
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class RenameTagCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('Tag properly renamed', $output);
|
||||
$this->assertStringContainsString('Tag properly renamed', $output);
|
||||
$renameTag->shouldHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class ProcessVisitsCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $lock;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->visitService = $this->prophesize(VisitService::class);
|
||||
$this->ipResolver = $this->prophesize(IpApiLocationResolver::class);
|
||||
|
@ -84,7 +84,7 @@ class ProcessVisitsCommandTest extends TestCase
|
|||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('Processing IP 1.2.3.0', $output);
|
||||
$this->assertStringContainsString('Processing IP 1.2.3.0', $output);
|
||||
$locateVisits->shouldHaveBeenCalledOnce();
|
||||
$resolveIpLocation->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class ProcessVisitsCommandTest extends TestCase
|
|||
|
||||
$this->assertInstanceOf(IpCannotBeLocatedException::class, $e);
|
||||
|
||||
$this->assertContains($message, $output);
|
||||
$this->assertStringContainsString($message, $output);
|
||||
$locateVisits->shouldHaveBeenCalledOnce();
|
||||
$resolveIpLocation->shouldNotHaveBeenCalled();
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class ProcessVisitsCommandTest extends TestCase
|
|||
|
||||
$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();
|
||||
$resolveIpLocation->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class ProcessVisitsCommandTest extends TestCase
|
|||
], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
sprintf('There is already an instance of the "%s" command', ProcessVisitsCommand::NAME),
|
||||
$output
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ class UpdateDbCommandTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $dbUpdater;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->dbUpdater = $this->prophesize(DbUpdaterInterface::class);
|
||||
|
||||
|
@ -41,7 +41,7 @@ class UpdateDbCommandTest extends TestCase
|
|||
$this->commandTester->execute([]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('GeoLite2 database properly updated', $output);
|
||||
$this->assertStringContainsString('GeoLite2 database properly updated', $output);
|
||||
$download->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class UpdateDbCommandTest extends TestCase
|
|||
$this->commandTester->execute([]);
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
|
|||
/** @var ConfigProvider */
|
||||
private $configProvider;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->configProvider = new ConfigProvider();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class ApplicationFactoryTest extends TestCase
|
|||
/** @var ApplicationFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new ApplicationFactory();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ abstract class DatabaseTestCase extends TestCase
|
|||
return self::$em;
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
foreach (static::ENTITIES_TO_EMPTY as $entityClass) {
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
|
|
|
@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
|
|||
/** @var ConfigProvider */
|
||||
private $configProvider;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->configProvider = new ConfigProvider();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class ShlinkTableTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $baseTable;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->baseTable = $this->prophesize(Table::class);
|
||||
$this->shlinkTable = new ShlinkTable($this->baseTable->reveal());
|
||||
|
|
|
@ -22,12 +22,12 @@ class CacheFactoryTest extends TestCase
|
|||
/** @var CacheFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new CacheFactory();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
putenv('APP_ENV');
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class DottedAccessConfigAbstractFactoryTest extends TestCase
|
|||
/** @var DottedAccessConfigAbstractFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new DottedAccessConfigAbstractFactory();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
|
|||
/** @var EmptyResponseImplicitOptionsMiddlewareFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class EntityManagerFactoryTest extends TestCase
|
|||
/** @var EntityManagerFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new EntityManagerFactory();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class LoggerFactoryTest extends TestCase
|
|||
/** @var LoggerFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new LoggerFactory();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class TranslatorFactoryTest extends TestCase
|
|||
/** @var TranslatorFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new TranslatorFactory();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class ImageBuilderFactoryTest extends TestCase
|
|||
/** @var ImageBuilderFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new ImageBuilderFactory();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class ImageFactoryTest extends TestCase
|
|||
/** @var ImageFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new ImageFactory();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class ChainIpLocationResolverTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $secondInnerResolver;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->firstInnerResolver = $this->prophesize(IpLocationResolverInterface::class);
|
||||
$this->secondInnerResolver = $this->prophesize(IpLocationResolverInterface::class);
|
||||
|
|
|
@ -26,7 +26,7 @@ class EmptyIpLocationResolverTest extends TestCase
|
|||
/** @var EmptyIpLocationResolver */
|
||||
private $resolver;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->resolver = new EmptyIpLocationResolver();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class DbUpdaterTest extends TestCase
|
|||
/** @var GeoLite2Options */
|
||||
private $options;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->httpClient = $this->prophesize(ClientInterface::class);
|
||||
$this->filesystem = $this->prophesize(Filesystem::class);
|
||||
|
|
|
@ -19,7 +19,7 @@ class GeoLite2LocationResolverTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $reader;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->reader = $this->prophesize(Reader::class);
|
||||
$this->resolver = new GeoLite2LocationResolver($this->reader->reveal());
|
||||
|
|
|
@ -8,6 +8,7 @@ use GuzzleHttp\Exception\TransferException;
|
|||
use GuzzleHttp\Psr7\Response;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Common\Exception\WrongIpException;
|
||||
use Shlinkio\Shlink\Common\IpGeolocation\IpApiLocationResolver;
|
||||
use function json_encode;
|
||||
|
||||
|
@ -18,7 +19,7 @@ class IpApiLocationResolverTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $client;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->client = $this->prophesize(Client::class);
|
||||
$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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Common\Exception\WrongIpException
|
||||
*/
|
||||
/** @test */
|
||||
public function guzzleExceptionThrowsShlinkException()
|
||||
{
|
||||
$this->client->get('http://ip-api.com/json/1.2.3.4')->willThrow(new TransferException())
|
||||
->shouldBeCalledOnce();
|
||||
$this->expectException(WrongIpException::class);
|
||||
$this->ipResolver->resolveIpLocation('1.2.3.4');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class ExceptionWithNewLineProcessorTest extends TestCase
|
|||
/** @var ExceptionWithNewLineProcessor */
|
||||
private $processor;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->processor = new ExceptionWithNewLineProcessor();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class CloseDbConnectionMiddlewareTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->handler = $this->prophesize(RequestHandlerInterface::class);
|
||||
$this->em = $this->prophesize(EntityManagerInterface::class);
|
||||
|
|
|
@ -13,7 +13,7 @@ class IpAddressMiddlewareFactoryTest extends TestCase
|
|||
{
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new IpAddressMiddlewareFactory();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class LocaleMiddlewareTest extends TestCase
|
|||
/** @var Translator */
|
||||
private $translator;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->translator = Translator::factory(['locale' => 'ru']);
|
||||
$this->middleware = new LocaleMiddleware($this->translator);
|
||||
|
|
|
@ -15,7 +15,7 @@ class PaginableRepositoryAdapterTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $repo;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->repo = $this->prophesize(PaginableRepositoryInterface::class);
|
||||
$this->adapter = new PaginableRepositoryAdapter($this->repo->reveal(), 'search', ['foo', 'bar'], 'order');
|
||||
|
|
|
@ -11,7 +11,7 @@ class PixelResponseTest extends TestCase
|
|||
/** @var PixelResponse */
|
||||
private $resp;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->resp = new PixelResponse();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use mikehaertl\wkhtmlto\Image;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Common\Exception\PreviewGenerationException;
|
||||
use Shlinkio\Shlink\Common\Image\ImageBuilder;
|
||||
use Shlinkio\Shlink\Common\Service\PreviewGenerator;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
@ -23,7 +24,7 @@ class PreviewGeneratorTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $filesystem;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->image = $this->prophesize(Image::class);
|
||||
$this->filesystem = $this->prophesize(Filesystem::class);
|
||||
|
@ -66,10 +67,7 @@ class PreviewGeneratorTest extends TestCase
|
|||
$this->assertEquals($expectedPath, $this->generator->generatePreview($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Common\Exception\PreviewGenerationException
|
||||
*/
|
||||
/** @test */
|
||||
public function errorWhileGeneratingPreviewThrowsException()
|
||||
{
|
||||
$url = 'http://foo.com';
|
||||
|
@ -82,6 +80,8 @@ class PreviewGeneratorTest extends TestCase
|
|||
$this->image->saveAs($expectedPath)->shouldBeCalledOnce();
|
||||
$this->image->getError()->willReturn('Error!!')->shouldBeCalledOnce();
|
||||
|
||||
$this->expectException(PreviewGenerationException::class);
|
||||
|
||||
$this->generator->generatePreview($url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class TranslatorExtensionTest extends TestCase
|
|||
/** @var TranslatorExtension */
|
||||
private $extension;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->extension = new TranslatorExtension($this->prophesize(Translator::class)->reveal());
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class ChronosDateTimeTypeTest extends TestCase
|
|||
/** @var ChronosDateTimeType */
|
||||
private $type;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
if (! Type::hasType(ChronosDateTimeType::CHRONOS_DATETIME)) {
|
||||
Type::addType(ChronosDateTimeType::CHRONOS_DATETIME, ChronosDateTimeType::class);
|
||||
|
|
|
@ -25,7 +25,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
|||
/** @var ShortUrlRepository */
|
||||
private $repo;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->repo = $this->getEntityManager()->getRepository(ShortUrl::class);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class TagRepositoryTest extends DatabaseTestCase
|
|||
/** @var TagRepository */
|
||||
private $repo;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->repo = $this->getEntityManager()->getRepository(Tag::class);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class VisitRepositoryTest extends DatabaseTestCase
|
|||
/** @var VisitRepository */
|
||||
private $repo;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->repo = $this->getEntityManager()->getRepository(Visit::class);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class PixelActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $visitTracker;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->prophesize(UrlShortener::class);
|
||||
$this->visitTracker = $this->prophesize(VisitsTracker::class);
|
||||
|
|
|
@ -30,7 +30,7 @@ class PreviewActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->previewGenerator = $this->prophesize(PreviewGenerator::class);
|
||||
$this->urlShortener = $this->prophesize(UrlShortener::class);
|
||||
|
|
|
@ -25,7 +25,7 @@ class QrCodeActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$router = $this->prophesize(RouterInterface::class);
|
||||
$router->generateUri(Argument::cetera())->willReturn('/foo/bar');
|
||||
|
|
|
@ -28,7 +28,7 @@ class RedirectActionTest extends TestCase
|
|||
/** @var Options\NotFoundShortUrlOptions */
|
||||
private $notFoundOptions;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->prophesize(UrlShortener::class);
|
||||
$this->visitTracker = $this->prophesize(VisitsTracker::class);
|
||||
|
|
|
@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
|
|||
/** @var ConfigProvider */
|
||||
private $configProvider;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->configProvider = new ConfigProvider();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class QrCodeCacheMiddlewareTest extends TestCase
|
|||
/** @var Cache */
|
||||
private $cache;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->cache = new ArrayCache();
|
||||
$this->middleware = new QrCodeCacheMiddleware($this->cache);
|
||||
|
|
|
@ -19,7 +19,7 @@ class NotFoundHandlerTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $renderer;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->renderer = $this->prophesize(TemplateRendererInterface::class);
|
||||
$this->delegate = new NotFoundHandler($this->renderer->reveal());
|
||||
|
|
|
@ -25,7 +25,7 @@ class DeleteShortUrlServiceTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$shortUrl = (new ShortUrl(''))->setShortCode('abc123')
|
||||
->setVisits(new ArrayCollection(map(range(0, 10), function () {
|
||||
|
|
|
@ -24,7 +24,7 @@ class ShortUrlServiceTest extends TestCase
|
|||
/** @var ObjectProphecy|EntityManagerInterface */
|
||||
private $em;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->em = $this->prophesize(EntityManagerInterface::class);
|
||||
$this->em->persist(Argument::any())->willReturn(null);
|
||||
|
|
|
@ -21,7 +21,7 @@ class TagServiceTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->em = $this->prophesize(EntityManagerInterface::class);
|
||||
$this->service = new TagService($this->em->reveal());
|
||||
|
|
|
@ -17,7 +17,10 @@ use Prophecy\Prophecy\MethodProphecy;
|
|||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
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\RuntimeException;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
|
||||
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
|
||||
|
@ -80,10 +83,7 @@ class UrlShortenerTest extends TestCase
|
|||
$this->assertEquals('0Q1Y', $shortUrl->getShortCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Core\Exception\RuntimeException
|
||||
*/
|
||||
/** @test */
|
||||
public function exceptionIsThrownWhenOrmThrowsException(): void
|
||||
{
|
||||
$conn = $this->prophesize(Connection::class);
|
||||
|
@ -93,6 +93,8 @@ class UrlShortenerTest extends TestCase
|
|||
$this->em->close()->shouldBeCalledOnce();
|
||||
|
||||
$this->em->flush()->willThrow(new ORMException());
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->urlShortener->urlToShortCode(
|
||||
new Uri('http://foobar.com/12345/hello?foo=bar'),
|
||||
[],
|
||||
|
@ -100,10 +102,7 @@ class UrlShortenerTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Core\Exception\InvalidUrlException
|
||||
*/
|
||||
/** @test */
|
||||
public function exceptionIsThrownWhenUrlDoesNotExist(): void
|
||||
{
|
||||
$this->setUrlShortener(true);
|
||||
|
@ -111,6 +110,8 @@ class UrlShortenerTest extends TestCase
|
|||
$this->httpClient->request(Argument::cetera())->willThrow(
|
||||
new ClientException('', $this->prophesize(Request::class)->reveal())
|
||||
);
|
||||
|
||||
$this->expectException(InvalidUrlException::class);
|
||||
$this->urlShortener->urlToShortCode(
|
||||
new Uri('http://foobar.com/12345/hello?foo=bar'),
|
||||
[],
|
||||
|
@ -227,12 +228,10 @@ class UrlShortenerTest extends TestCase
|
|||
$this->assertSame($shortUrl, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Core\Exception\InvalidShortCodeException
|
||||
*/
|
||||
/** @test */
|
||||
public function invalidCharSetThrowsException(): void
|
||||
{
|
||||
$this->expectException(InvalidShortCodeException::class);
|
||||
$this->urlShortener->shortCodeToUrl('&/(');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class VisitServiceTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->em = $this->prophesize(EntityManager::class);
|
||||
$this->visitService = new VisitService($this->em->reveal());
|
||||
|
|
|
@ -25,7 +25,7 @@ class VisitsTrackerTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->em = $this->prophesize(EntityManager::class);
|
||||
$this->visitsTracker = new VisitsTracker($this->em->reveal());
|
||||
|
|
|
@ -22,7 +22,7 @@ class AuthenticateActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $jwtService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
|
||||
$this->jwtService = $this->prophesize(JWTService::class);
|
||||
|
|
|
@ -16,7 +16,7 @@ class HealthActionFactoryTest extends TestCase
|
|||
/** @var Action\HealthActionFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new Action\HealthActionFactory();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class HealthActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $conn;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->conn = $this->prophesize(Connection::class);
|
||||
$this->action = new HealthAction($this->conn->reveal(), new AppOptions(['version' => '1.2.3']));
|
||||
|
|
|
@ -25,7 +25,7 @@ class CreateShortUrlActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->prophesize(UrlShortener::class);
|
||||
$this->action = new CreateShortUrlAction($this->urlShortener->reveal(), [
|
||||
|
@ -97,7 +97,7 @@ class CreateShortUrlActionTest extends TestCase
|
|||
]);
|
||||
$response = $this->action->handle($request);
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertContains(RestUtils::INVALID_SLUG_ERROR, (string) $response->getBody());
|
||||
$this->assertStringContainsString(RestUtils::INVALID_SLUG_ERROR, (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ class DeleteShortUrlActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $service;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->service = $this->prophesize(DeleteShortUrlServiceInterface::class);
|
||||
$this->action = new DeleteShortUrlAction($this->service->reveal());
|
||||
|
|
|
@ -21,7 +21,7 @@ class EditShortUrlActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $shortUrlService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class);
|
||||
$this->action = new EditShortUrlAction($this->shortUrlService->reveal());
|
||||
|
|
|
@ -18,7 +18,7 @@ class EditShortUrlTagsActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $shortUrlService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->shortUrlService = $this->prophesize(ShortUrlService::class);
|
||||
$this->action = new EditShortUrlTagsAction($this->shortUrlService->reveal());
|
||||
|
|
|
@ -19,7 +19,7 @@ class ListShortUrlsActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $service;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->service = $this->prophesize(ShortUrlService::class);
|
||||
$this->action = new ListShortUrlsAction($this->service->reveal(), [
|
||||
|
|
|
@ -22,7 +22,7 @@ class ResolveShortUrlActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->prophesize(UrlShortener::class);
|
||||
$this->action = new ResolveShortUrlAction($this->urlShortener->reveal(), []);
|
||||
|
|
|
@ -25,7 +25,7 @@ class SingleStepCreateShortUrlActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlShortener = $this->prophesize(UrlShortenerInterface::class);
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class);
|
||||
|
|
|
@ -18,7 +18,7 @@ class CreateTagsActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
$this->action = new CreateTagsAction($this->tagService->reveal());
|
||||
|
|
|
@ -17,7 +17,7 @@ class DeleteTagsActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
$this->action = new DeleteTagsAction($this->tagService->reveal());
|
||||
|
|
|
@ -19,7 +19,7 @@ class ListTagsActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
$this->action = new ListTagsAction($this->tagService->reveal());
|
||||
|
|
|
@ -19,7 +19,7 @@ class UpdateTagActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
$this->action = new UpdateTagAction($this->tagService->reveal());
|
||||
|
|
|
@ -23,7 +23,7 @@ class GetVisitsActionTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $visitsTracker;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->visitsTracker = $this->prophesize(VisitsTracker::class);
|
||||
$this->action = new GetVisitsAction($this->visitsTracker->reveal());
|
||||
|
|
|
@ -13,7 +13,7 @@ class AuthenticationPluginManagerFactoryTest extends TestCase
|
|||
/** @var AuthenticationPluginManagerFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->factory = new AuthenticationPluginManagerFactory();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase;
|
|||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||
use Shlinkio\Shlink\Rest\Authentication\JWTService;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
|
||||
use function time;
|
||||
|
||||
class JWTServiceTest extends TestCase
|
||||
|
@ -15,7 +16,7 @@ class JWTServiceTest extends TestCase
|
|||
/** @var JWTService */
|
||||
private $service;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->service = new JWTService(new AppOptions([
|
||||
'name' => 'ShlinkTest',
|
||||
|
@ -83,12 +84,10 @@ class JWTServiceTest extends TestCase
|
|||
$this->assertEquals($originalPayload, $this->service->getPayload($token));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Rest\Exception\AuthenticationException
|
||||
*/
|
||||
/** @test */
|
||||
public function getPayloadThrowsExceptionWithIncorrectTokens()
|
||||
{
|
||||
$this->expectException(AuthenticationException::class);
|
||||
$this->service->getPayload('invalidToken');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class ApiKeyHeaderPluginTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class);
|
||||
$this->plugin = new ApiKeyHeaderPlugin($this->apiKeyService->reveal());
|
||||
|
|
|
@ -19,7 +19,7 @@ class AuthorizationHeaderPluginTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $jwtService;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->jwtService = $this->prophesize(JWTServiceInterface::class);
|
||||
$this->plugin = new AuthorizationHeaderPlugin($this->jwtService->reveal());
|
||||
|
|
|
@ -22,7 +22,7 @@ class RequestToAuthPluginTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $pluginManager;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->pluginManager = $this->prophesize(AuthenticationPluginManagerInterface::class);
|
||||
$this->requestToPlugin = new RequestToHttpAuthPlugin($this->pluginManager->reveal());
|
||||
|
|
|
@ -11,7 +11,7 @@ class ConfigProviderTest extends TestCase
|
|||
/** @var ConfigProvider */
|
||||
private $configProvider;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->configProvider = new ConfigProvider();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class JsonErrorResponseGeneratorTest extends TestCase
|
|||
/** @var JsonErrorResponseGenerator */
|
||||
private $errorHandler;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->errorHandler = new JsonErrorResponseGenerator();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class AuthenticationMiddlewareTest extends TestCase
|
|||
/** @var callable */
|
||||
private $dummyMiddleware;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->requestToPlugin = $this->prophesize(RequestToHttpAuthPluginInterface::class);
|
||||
$this->middleware = new AuthenticationMiddleware($this->requestToPlugin->reveal(), [AuthenticateAction::class]);
|
||||
|
|
|
@ -19,7 +19,7 @@ class BodyParserMiddlewareTest extends TestCase
|
|||
/** @var BodyParserMiddleware */
|
||||
private $middleware;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->middleware = new BodyParserMiddleware();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class CrossDomainMiddlewareTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $delegate;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->middleware = new CrossDomainMiddleware();
|
||||
$this->delegate = $this->prophesize(RequestHandlerInterface::class);
|
||||
|
|
|
@ -19,7 +19,7 @@ class PathVersionMiddlewareTest extends TestCase
|
|||
/** @var PathVersionMiddleware */
|
||||
private $middleware;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->middleware = new PathVersionMiddleware();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
|
|||
/** @var RequestHandlerInterface */
|
||||
private $requestHandler;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->middleware = new CreateShortUrlContentNegotiationMiddleware();
|
||||
$this->requestHandler = $this->prophesize(RequestHandlerInterface::class);
|
||||
|
|
|
@ -18,7 +18,7 @@ class ShortCodePathMiddlewareTest extends TestCase
|
|||
private $middleware;
|
||||
private $requestHandler;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->middleware = new ShortCodePathMiddleware();
|
||||
$this->requestHandler = $this->prophesize(RequestHandlerInterface::class);
|
||||
|
@ -37,8 +37,8 @@ class ShortCodePathMiddlewareTest extends TestCase
|
|||
$withUri = $request->withUri(Argument::that(function (UriInterface $uri) {
|
||||
$path = $uri->getPath();
|
||||
|
||||
Assert::assertContains('/short-urls', $path);
|
||||
Assert::assertNotContains('/short-codes', $path);
|
||||
Assert::assertStringContainsString('/short-urls', $path);
|
||||
Assert::assertStringNotContainsString('/short-codes', $path);
|
||||
|
||||
return $uri;
|
||||
}))->willReturn($request->reveal());
|
||||
|
|
|
@ -9,6 +9,7 @@ use Doctrine\ORM\EntityRepository;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
|
||||
|
||||
|
@ -19,7 +20,7 @@ class ApiKeyServiceTest extends TestCase
|
|||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->em = $this->prophesize(EntityManager::class);
|
||||
$this->service = new ApiKeyService($this->em->reveal());
|
||||
|
@ -105,10 +106,7 @@ class ApiKeyServiceTest extends TestCase
|
|||
$this->assertTrue($this->service->check('12345'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Common\Exception\InvalidArgumentException
|
||||
*/
|
||||
/** @test */
|
||||
public function disableThrowsExceptionWhenNoTokenIsFound()
|
||||
{
|
||||
$repo = $this->prophesize(EntityRepository::class);
|
||||
|
@ -116,6 +114,7 @@ class ApiKeyServiceTest extends TestCase
|
|||
->shouldBeCalledOnce();
|
||||
$this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->service->disable('12345');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue