mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Converted ValidationException into a problem details exception
This commit is contained in:
@@ -10,11 +10,11 @@ use Prophecy\Argument;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Exception\ValidationException;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Service\UrlShortenerInterface;
|
||||
use Shlinkio\Shlink\Rest\Action\ShortUrl\SingleStepCreateShortUrlAction;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
|
||||
class SingleStepCreateShortUrlActionTest extends TestCase
|
||||
@@ -47,14 +47,10 @@ class SingleStepCreateShortUrlActionTest extends TestCase
|
||||
$request = (new ServerRequest())->withQueryParams(['apiKey' => 'abc123']);
|
||||
$findApiKey = $this->apiKeyService->check('abc123')->willReturn(false);
|
||||
|
||||
/** @var JsonResponse $resp */
|
||||
$resp = $this->action->handle($request);
|
||||
$payload = $resp->getPayload();
|
||||
$this->expectException(ValidationException::class);
|
||||
$findApiKey->shouldBeCalledOnce();
|
||||
|
||||
$this->assertEquals(400, $resp->getStatusCode());
|
||||
$this->assertEquals('INVALID_ARGUMENT', $payload['error']);
|
||||
$this->assertEquals('Provided data is not valid', $payload['message']);
|
||||
$findApiKey->shouldHaveBeenCalled();
|
||||
$this->action->handle($request);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@@ -63,14 +59,10 @@ class SingleStepCreateShortUrlActionTest extends TestCase
|
||||
$request = (new ServerRequest())->withQueryParams(['apiKey' => 'abc123']);
|
||||
$findApiKey = $this->apiKeyService->check('abc123')->willReturn(true);
|
||||
|
||||
/** @var JsonResponse $resp */
|
||||
$resp = $this->action->handle($request);
|
||||
$payload = $resp->getPayload();
|
||||
$this->expectException(ValidationException::class);
|
||||
$findApiKey->shouldBeCalledOnce();
|
||||
|
||||
$this->assertEquals(400, $resp->getStatusCode());
|
||||
$this->assertEquals('INVALID_ARGUMENT', $payload['error']);
|
||||
$this->assertEquals('Provided data is not valid', $payload['message']);
|
||||
$findApiKey->shouldHaveBeenCalled();
|
||||
$this->action->handle($request);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
||||
Reference in New Issue
Block a user