for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace ShlinkioApiTest\Shlink\Rest\Action;
use Shlinkio\Shlink\Rest\Util\RestUtils;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
class DeleteShortUrlActionTest extends ApiTestCase
{
/** @test */
public function notFoundErrorIsReturnWhenDeletingInvalidUrl(): void
$resp = $this->callApiWithKey(self::METHOD_DELETE, '/short-urls/invalid');
['error' => $error] = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(RestUtils::INVALID_SHORTCODE_ERROR, $error);
Shlinkio\Shlink\Rest\Uti...INVALID_SHORTCODE_ERROR
If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated annotation
ignore-deprecated
$this->assertEquals(/** @scrutinizer ignore-deprecated */ RestUtils::INVALID_SHORTCODE_ERROR, $error);
}
public function unprocessableEntityIsReturnedWhenTryingToDeleteUrlWithTooManyVisits(): void
// Generate visits first
for ($i = 0; $i < 20; $i++) {
$this->assertEquals(self::STATUS_FOUND, $this->callShortUrl('abc123')->getStatusCode());
$resp = $this->callApiWithKey(self::METHOD_DELETE, '/short-urls/abc123');
$this->assertEquals(self::STATUS_UNPROCESSABLE_ENTITY, $resp->getStatusCode());
$this->assertEquals(RestUtils::INVALID_SHORTCODE_DELETION_ERROR, $error);
Shlinkio\Shlink\Rest\Uti...HORTCODE_DELETION_ERROR
$this->assertEquals(/** @scrutinizer ignore-deprecated */ RestUtils::INVALID_SHORTCODE_DELETION_ERROR, $error);