Created API tests for errors when editting short URL tags

This commit is contained in:
Alejandro Celaya
2019-11-21 18:49:55 +01:00
parent 34e60ec5b8
commit 8607d58e18
3 changed files with 41 additions and 39 deletions

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace ShlinkioTest\Shlink\Rest\Action\ShortUrl;
use Exception;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Log\LoggerInterface;
@@ -79,26 +78,4 @@ class ListShortUrlsActionTest extends TestCase
'tags' => $tags = ['one', 'two'],
], 2, null, $tags, $orderBy];
}
/** @test */
public function anExceptionReturnsErrorResponse(): void
{
$page = 3;
$e = new Exception();
$this->service->listShortUrls($page, null, [], null)->willThrow($e)
->shouldBeCalledOnce();
$logError = $this->logger->error(
'Unexpected error while listing short URLs. {e}',
['e' => $e]
)->will(function () {
});
$response = $this->action->handle((new ServerRequest())->withQueryParams([
'page' => $page,
]));
$this->assertEquals(500, $response->getStatusCode());
$logError->shouldHaveBeenCalledOnce();
}
}