From a9914db75e9dde97fb21bc49b8373f711b8c6db8 Mon Sep 17 00:00:00 2001 From: Neverdane Date: Tue, 26 Jan 2016 23:04:42 +0100 Subject: [PATCH] Cover all SQS addMessages conditions with tests Some addMessages conditions weren't tested which reduced the unit tests code coverage. --- tests/units/Adapter/NullAdapter.php | 6 ++++++ tests/units/Adapter/SQSAdapter.php | 26 +++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/units/Adapter/NullAdapter.php b/tests/units/Adapter/NullAdapter.php index 8255b23..20d7070 100644 --- a/tests/units/Adapter/NullAdapter.php +++ b/tests/units/Adapter/NullAdapter.php @@ -13,6 +13,12 @@ public function testNullAdapterAddMessage() $this->given($NullAdapter)->class($NullAdapter->addMessage('testQueue', 'test Message one'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface'); } + public function testNullAdapterAddMessages() + { + $NullAdapter = new \ReputationVIP\QueueClient\Adapter\NullAdapter(); + $this->given($NullAdapter)->class($NullAdapter->addMessages('testQueue', ['test Message one']))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface'); + } + public function testNullAdapterGetMessages() { $NullAdapter = new \ReputationVIP\QueueClient\Adapter\NullAdapter(); diff --git a/tests/units/Adapter/SQSAdapter.php b/tests/units/Adapter/SQSAdapter.php index 27b1c79..569224d 100644 --- a/tests/units/Adapter/SQSAdapter.php +++ b/tests/units/Adapter/SQSAdapter.php @@ -62,7 +62,31 @@ public function testSQSAdapterAddMessages() $mockSqsClient->getMockController()->sendMessageBatch = function () { }; $this->given($SQSAdapter) - ->class($SQSAdapter->addMessages('testQueue', ['test message', 'test message 2']))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface'); + ->class($SQSAdapter->addMessages('testQueue', array_fill(0, 11, 'test message')))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface'); + } + + public function testSQSAdapterAddMessagesWithEmptyMessage() + { + $this->mockGenerator->orphanize('__construct'); + $this->mockGenerator->shuntParentClassCalls(); + $mockSqsClient = new \mock\Aws\Sqs\SqsClient; + $SQSAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient); + + $this->exception(function() use($SQSAdapter) { + $SQSAdapter->addMessages('testQueue', ['test message', '']); + }); + } + + public function testSQSAdapterAddMessagesWithEmptyQueueName() + { + $this->mockGenerator->orphanize('__construct'); + $this->mockGenerator->shuntParentClassCalls(); + $mockSqsClient = new \mock\Aws\Sqs\SqsClient; + $SQSAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient); + + $this->exception(function() use($SQSAdapter) { + $SQSAdapter->addMessages('', ['']); + }); } public function testSQSAdapterGetMessagesWithEmptyQueueName()