From 2e6e042914ffa7c1ab4b1d3d562ec2af7acdf98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Fri, 30 Apr 2021 15:45:20 +0200 Subject: [PATCH] Add test cases for SendingThrottlingHandler [MAILPOET-3588] --- .../SendingThrottlingHandlerTest.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php b/tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php index eb7bc738e9..408984a47c 100644 --- a/tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php +++ b/tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php @@ -34,6 +34,23 @@ class SendingThrottlingHandlerTest extends \MailPoetTest { $this->throttlingHandler->throttleBatchSize(); $this->throttlingHandler->processSuccess(); $throttlingSettings = $this->settings->get(SendingThrottlingHandler::SETTINGS_KEY); - expect($throttlingSettings['success_in_row'])->equals(1); + expect($throttlingSettings['success_count'])->equals(1); + } + + public function testItSetsBatchSizeMinimumToOne(): void { + for ($i = 1; $i <= 10; $i++) { + $this->throttlingHandler->throttleBatchSize(); + } + expect($this->throttlingHandler->getBatchSize())->equals(1); + } + + public function testInIncreasesBatchSizeBack(): void { + $this->settings->set(SendingThrottlingHandler::SETTINGS_KEY, []); + $this->throttlingHandler->throttleBatchSize(); + expect($this->throttlingHandler->getBatchSize())->equals(SendingThrottlingHandler::BATCH_SIZE / 2); + for ($i = 1; $i <= SendingThrottlingHandler::SUCCESS_THRESHOLD_TO_INCREASE; $i++) { + $this->throttlingHandler->processSuccess(); + } + expect($this->throttlingHandler->getBatchSize())->equals(SendingThrottlingHandler::BATCH_SIZE); } }