Standardized ordering field handling and added validation for short URLs list

This commit is contained in:
Alejandro Celaya
2022-01-09 11:23:27 +01:00
parent d0c9f5a776
commit 2abcaf02e2
12 changed files with 68 additions and 92 deletions

View File

@@ -11,7 +11,6 @@ use Shlinkio\Shlink\Common\Paginator\Paginator;
use Shlinkio\Shlink\Common\Paginator\Util\PagerfantaUtilsTrait;
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Model\ShortUrlsOrdering;
use Shlinkio\Shlink\Core\Model\ShortUrlsParams;
use Shlinkio\Shlink\Core\Service\ShortUrlServiceInterface;
use Shlinkio\Shlink\Core\Validation\ShortUrlsParamsInputFilter;
@@ -135,7 +134,7 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
ShortUrlsParamsInputFilter::SEARCH_TERM => $searchTerm,
ShortUrlsParamsInputFilter::TAGS => $tags,
ShortUrlsParamsInputFilter::TAGS_MODE => $tagsMode,
ShortUrlsOrdering::ORDER_BY => $orderBy,
ShortUrlsParamsInputFilter::ORDER_BY => $orderBy,
ShortUrlsParamsInputFilter::START_DATE => $startDate?->toAtomString(),
ShortUrlsParamsInputFilter::END_DATE => $endDate?->toAtomString(),
];

View File

@@ -263,10 +263,10 @@ class ListShortUrlsCommandTest extends TestCase
public function provideOrderBy(): iterable
{
yield [[], null];
yield [['--order-by' => 'foo'], 'foo'];
yield [['--order-by' => 'foo,ASC'], 'foo-ASC'];
yield [['--order-by' => 'bar,DESC'], 'bar-DESC'];
yield [['--order-by' => 'baz-DESC'], 'baz-DESC'];
yield [['--order-by' => 'visits'], 'visits'];
yield [['--order-by' => 'longUrl,ASC'], 'longUrl-ASC'];
yield [['--order-by' => 'shortCode,DESC'], 'shortCode-DESC'];
yield [['--order-by' => 'title-DESC'], 'title-DESC'];
}
/** @test */