From 3126998212c94f92f37cb1f22cbc7130cd17e67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Fri, 30 Apr 2021 14:07:47 +0200 Subject: [PATCH] Add integration test for SendingThrottlingHandler [MAILPOET-3588] --- .../SendingThrottlingHandlerTest.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php diff --git a/tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php b/tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php new file mode 100644 index 0000000000..eb7bc738e9 --- /dev/null +++ b/tests/integration/Cron/Workers/SendingQueue/SendingThrottlingHandlerTest.php @@ -0,0 +1,39 @@ +throttlingHandler = $this->diContainer->get(SendingThrottlingHandler::class); + $this->settings = $this->diContainer->get(SettingsController::class); + } + + public function testItReturnsDefaultBatchSize(): void { + $batchSize = $this->throttlingHandler->getBatchSize(); + expect($batchSize)->equals(SendingThrottlingHandler::BATCH_SIZE); + } + + public function testItThrottlesBatchSizeToHalf(): void { + $batchSize = $this->throttlingHandler->getBatchSize(); + expect($batchSize)->equals(SendingThrottlingHandler::BATCH_SIZE); + expect($this->throttlingHandler->throttleBatchSize())->equals($batchSize / 2); + } + + public function testItIncreaseSuccessRequestCountInRow(): void { + $this->throttlingHandler->throttleBatchSize(); + $this->throttlingHandler->processSuccess(); + $throttlingSettings = $this->settings->get(SendingThrottlingHandler::SETTINGS_KEY); + expect($throttlingSettings['success_in_row'])->equals(1); + } +}