Skip to content

Commit d0cc1c6

Browse files
author
Derek Drummond
committed
Added unit test to achieve 100% code coverage
1 parent 5d83a78 commit d0cc1c6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/QueueTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,24 @@ public function ensureGetIndexWithBadAfterSortValue()
141141
$this->queue->ensureGetIndex([], ['field' => 'NotAnInt']);
142142
}
143143

144+
/**
145+
* Verifies the behaviour of the Queue when it cannot create an index after 5 attempts.
146+
*
147+
* @test
148+
* @covers ::ensureGetIndex
149+
* @expectedException \Exception
150+
* @expectedExceptionMessage couldnt create index after 5 attempts
151+
*/
152+
public function ensureIndexCannotBeCreatedAfterFiveAttempts()
153+
{
154+
$mockCollection = $this->getMockBuilder('\MongoDB\Collection')->disableOriginalConstructor()->getMock();
155+
156+
$mockCollection->method('listIndexes')->willReturn([]);
157+
158+
$queue = new Queue($mockCollection);
159+
$queue->ensureCountIndex(['type' => 1], false);
160+
}
161+
144162
/**
145163
* @test
146164
* @covers ::ensureCountIndex

0 commit comments

Comments
 (0)