Improved API tests to cover exlucding disabled URLs from lists

This commit is contained in:
Alejandro Celaya 2022-12-11 13:38:11 +01:00
parent 0c3523c34a
commit 201f25e0ad
3 changed files with 29 additions and 5 deletions

View file

@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
## [Unreleased]
### Added
* [#1612](https://github.com/shlinkio/shlink/issues/1612) Allowed to filter short URLs out of lists, when `validUntil` date is in the past or have reached their maximum amount of visits.
This can be done by:
* Providing `excludeMaxVisitsReached=true` and/or `excludePastValidUntil=true` to the `GET /short-urls` endpoint.
* Providing `--exclude-max-visits-reached` and/or `--exclude-past-valid-until` to the `short-urls:list` command.
* [#1616](https://github.com/shlinkio/shlink/issues/1616) Added support to import orphan visits when importing short URLs from another Shlink instance.
* [#1519](https://github.com/shlinkio/shlink/issues/1519) Allowing to search short URLs by default domain.
* [#1555](https://github.com/shlinkio/shlink/issues/1555) Added full support for PHP 8.2, pdating the dockr image to this version.

View file

@ -22,7 +22,7 @@ class ListShortUrlsTest extends ApiTestCase
'meta' => [
'validSince' => null,
'validUntil' => null,
'maxVisits' => null,
'maxVisits' => 2,
],
'domain' => null,
'title' => 'My cool title',
@ -38,7 +38,7 @@ class ListShortUrlsTest extends ApiTestCase
'tags' => [],
'meta' => [
'validSince' => null,
'validUntil' => null,
'validUntil' => '2020-05-01T00:00:00+00:00',
'maxVisits' => null,
],
'domain' => null,
@ -147,6 +147,20 @@ class ListShortUrlsTest extends ApiTestCase
self::SHORT_URL_SHLINK_WITH_TITLE,
self::SHORT_URL_DOCS,
], 'valid_api_key'];
yield [['excludePastValidUntil' => 'true'], [
self::SHORT_URL_CUSTOM_DOMAIN,
self::SHORT_URL_CUSTOM_SLUG,
self::SHORT_URL_META,
self::SHORT_URL_CUSTOM_SLUG_AND_DOMAIN,
self::SHORT_URL_SHLINK_WITH_TITLE,
], 'valid_api_key'];
yield [['excludeMaxVisitsReached' => 'true'], [
self::SHORT_URL_CUSTOM_DOMAIN,
self::SHORT_URL_CUSTOM_SLUG,
self::SHORT_URL_META,
self::SHORT_URL_CUSTOM_SLUG_AND_DOMAIN,
self::SHORT_URL_DOCS,
], 'valid_api_key'];
yield [['orderBy' => 'shortCode'], [
self::SHORT_URL_SHLINK_WITH_TITLE,
self::SHORT_URL_CUSTOM_SLUG,

View file

@ -36,6 +36,7 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
'tags' => ['foo'],
'title' => 'My cool title',
'crawlable' => true,
'maxVisits' => 2,
]), $relationResolver),
'2018-05-01',
);
@ -61,9 +62,11 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
$manager->persist($customShortUrl);
$ghiShortUrl = $this->setShortUrlDate(
ShortUrl::fromMeta(ShortUrlCreation::fromRawData(
['customSlug' => 'ghi789', 'longUrl' => 'https://shlink.io/documentation/'],
)),
ShortUrl::fromMeta(ShortUrlCreation::fromRawData([
'customSlug' => 'ghi789',
'longUrl' => 'https://shlink.io/documentation/',
'validUntil' => Chronos::parse('2020-05-01'), // In the past
])),
'2018-05-01',
);
$manager->persist($ghiShortUrl);