From 54905e5ed6fba18c65c37b75e29ba8424ed3f19a Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 8 Feb 2021 11:09:38 +0100 Subject: [PATCH 1/3] Fix clean up command on specifying 0 as retention number of days --- features/cleaning_queue.feature | 10 ++++++++++ src/Command/QueueCleanupCommand.php | 2 +- tests/Behat/Context/Setup/QueueContext.php | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/features/cleaning_queue.feature b/features/cleaning_queue.feature index b97e7f34..b0188a60 100644 --- a/features/cleaning_queue.feature +++ b/features/cleaning_queue.feature @@ -27,3 +27,13 @@ Feature: cleaning queue When I clean the queue specifying 16 days of retention Then I should be notified that 1 item has been deleted And there shouldn't be any more item to clean + + @cli + Scenario: Cleaning the queue specifying zero as retention number of days + Given there is an already imported item with identifier "braided-hat-m" for the "Product" importer in the Akeneo queue + And this item has been imported now + And there is an already imported item with identifier "braided-hat-s" for the "Product" importer in the Akeneo queue + And this item has been imported 20 days ago + When I clean the queue specifying 0 days of retention + Then I should be notified that 2 item has been deleted + And there shouldn't be any more item to clean diff --git a/src/Command/QueueCleanupCommand.php b/src/Command/QueueCleanupCommand.php index 2057b58f..dad06301 100644 --- a/src/Command/QueueCleanupCommand.php +++ b/src/Command/QueueCleanupCommand.php @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $numberOfDays = self::DEFAULT_DAYS; // get the number of days from user $numberOfDaysEntered = $input->getArgument(self::DAYS_ARGUMENT_NAME); - if ($numberOfDaysEntered) { + if ($numberOfDaysEntered !== null) { if (!is_string($numberOfDaysEntered) || (int) $numberOfDaysEntered < 0) { $output->writeln('Sorry, the number of days entered is not valid!'); diff --git a/tests/Behat/Context/Setup/QueueContext.php b/tests/Behat/Context/Setup/QueueContext.php index 49efea18..19fade9f 100644 --- a/tests/Behat/Context/Setup/QueueContext.php +++ b/tests/Behat/Context/Setup/QueueContext.php @@ -83,4 +83,13 @@ public function thisItemHasBeenImportedDaysAgo(QueueItemInterface $queueItem, in $queueItem->setImportedAt(new \DateTime("$days days ago")); $this->queueItemRepository->add($queueItem); } + + /** + * @Given /^(this item) has been imported now$/ + */ + public function thisItemHasBeenImportedNow(QueueItemInterface $queueItem) + { + $queueItem->setImportedAt(new \DateTime()); + $this->queueItemRepository->add($queueItem); + } } From 661be0dfcaf9830a74afabf91e76b3c501a167c1 Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 8 Feb 2021 11:50:27 +0100 Subject: [PATCH 2/3] Update cleaning_queue.feature --- features/cleaning_queue.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/cleaning_queue.feature b/features/cleaning_queue.feature index b0188a60..7c85e917 100644 --- a/features/cleaning_queue.feature +++ b/features/cleaning_queue.feature @@ -35,5 +35,5 @@ Feature: cleaning queue And there is an already imported item with identifier "braided-hat-s" for the "Product" importer in the Akeneo queue And this item has been imported 20 days ago When I clean the queue specifying 0 days of retention - Then I should be notified that 2 item has been deleted - And there shouldn't be any more item to clean + Then I should be notified that 2 items have been deleted + And there shouldn't be any more items to clean From 69d4a7d41b0a7511f56a20c858f0e91ea8225f8d Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 8 Feb 2021 12:04:39 +0100 Subject: [PATCH 3/3] Fix to match expression on queue clean up scenarios --- tests/Behat/Context/Cli/QueueCleanupCommandContext.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Behat/Context/Cli/QueueCleanupCommandContext.php b/tests/Behat/Context/Cli/QueueCleanupCommandContext.php index ba33e1dc..41ac6c20 100644 --- a/tests/Behat/Context/Cli/QueueCleanupCommandContext.php +++ b/tests/Behat/Context/Cli/QueueCleanupCommandContext.php @@ -57,7 +57,7 @@ public function iShouldBeNotifiedThatThereAreNoItemsToClean() } /** - * @Then /^I should be notified that (\d+) item has been deleted$/ + * @Then /^I should be notified that (\d+) item[s]? (has|have) been deleted$/ */ public function iShouldBeNotifiedThatItemHasBeenDeleted(int $count) { @@ -66,7 +66,7 @@ public function iShouldBeNotifiedThatItemHasBeenDeleted(int $count) } /** - * @Then /^there shouldn\'t be any more item to clean$/ + * @Then /^there shouldn\'t be any more item[s]? to clean$/ */ public function thereShouldntBeAnyMoreItemToClean() {