Test non-interactivity on DeleteExpiredShortUrlsCommand

This commit is contained in:
Alejandro Celaya 2024-04-03 19:21:39 +02:00
parent 3881996560
commit b7db676cba
2 changed files with 7 additions and 6 deletions

View file

@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* [#2077](https://github.com/shlinkio/shlink/issues/2077) When sending visits to Matomo, the short URL title is now used as document title in matomo.
* [#2059](https://github.com/shlinkio/shlink/issues/2059) Add new `short-url:delete-expired` command that can be used to programmatically delete expired short URLs.
Expired short URLs are those that have a `calidUntil` date in the past, or optionally, that have reached the max amount of visits.
Expired short URLs are those that have a `validUntil` date in the past, or optionally, that have reached the max amount of visits.
This command can be run periodically by those who create many disposable URLs which are valid only for a period of time, and then can be deleted to save space.

View file

@ -42,16 +42,17 @@ class DeleteExpiredShortUrlsCommandTest extends TestCase
}
#[Test]
#[TestWith([[], true])]
#[TestWith([['--force' => true], false])]
#[TestWith([['-f' => true], false])]
public function deletionIsExecutedByDefault(array $input, bool $expectsWarning): void
#[TestWith([[], [], true])]
#[TestWith([['--force' => true], [], false])]
#[TestWith([['-f' => true], [], false])]
#[TestWith([[], ['interactive' => false], false])]
public function deletionIsExecutedByDefault(array $input, array $options, bool $expectsWarning): void
{
$this->service->expects($this->never())->method('countExpiredShortUrls');
$this->service->expects($this->once())->method('deleteExpiredShortUrls')->willReturn(5);
$this->commandTester->setInputs(['y']);
$this->commandTester->execute($input);
$this->commandTester->execute($input, $options);
$output = $this->commandTester->getDisplay();
$status = $this->commandTester->getStatusCode();