Skip to content

Commit

Permalink
Cover all SQS addMessages conditions with tests
Browse files Browse the repository at this point in the history
Some addMessages conditions weren't tested which reduced
the unit tests code coverage.
  • Loading branch information
neverdane committed Jan 26, 2016
1 parent 09e53ab commit a9914db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/units/Adapter/NullAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
26 changes: 25 additions & 1 deletion tests/units/Adapter/SQSAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a9914db

Please sign in to comment.