Skip to content

Commit d10dc84

Browse files
committed
PHPLIB-63: Empty input to createIndexes() is a NOP
1 parent 75f8348 commit d10dc84

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ public function createIndex($key, array $options = array())
290290
*/
291291
public function createIndexes(array $indexes)
292292
{
293+
if (empty($indexes)) {
294+
return array();
295+
}
296+
293297
foreach ($indexes as $i => $index) {
294298
if ( ! is_array($index)) {
295299
throw new UnexpectedTypeException($index, 'array');

tests/CollectionFunctionalTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public function testCreateIndexes()
132132
});
133133
}
134134

135+
public function testCreateIndexesWithEmptyInputIsNop()
136+
{
137+
$this->assertSame(array(), $this->collection->createIndexes(array()));
138+
}
139+
135140
public function testDropIndex()
136141
{
137142
$this->assertSame('x_1', $this->collection->createIndex(array('x' => 1)));

0 commit comments

Comments
 (0)