Commit 2083eede authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-63: Empty input to createIndexes() is a NOP

parent 39cf9182
...@@ -290,6 +290,10 @@ class Collection ...@@ -290,6 +290,10 @@ class Collection
*/ */
public function createIndexes(array $indexes) public function createIndexes(array $indexes)
{ {
if (empty($indexes)) {
return array();
}
foreach ($indexes as $i => $index) { foreach ($indexes as $i => $index) {
if ( ! is_array($index)) { if ( ! is_array($index)) {
throw new UnexpectedTypeException($index, 'array'); throw new UnexpectedTypeException($index, 'array');
......
...@@ -132,6 +132,11 @@ class CollectionFunctionalTest extends FunctionalTestCase ...@@ -132,6 +132,11 @@ class CollectionFunctionalTest extends FunctionalTestCase
}); });
} }
public function testCreateIndexesWithEmptyInputIsNop()
{
$this->assertSame(array(), $this->collection->createIndexes(array()));
}
public function testDropIndex() public function testDropIndex()
{ {
$this->assertSame('x_1', $this->collection->createIndex(array('x' => 1))); $this->assertSame('x_1', $this->collection->createIndex(array('x' => 1)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment