From 1a9d5a11ffff12866ce0d8f126689f6e21297e4f Mon Sep 17 00:00:00 2001 From: Paul Klimov Date: Tue, 3 Dec 2013 15:28:35 +0200 Subject: [PATCH] Mongo Collection "deleteAllIndexes" return result fixed. --- extensions/mongo/Collection.php | 2 +- tests/unit/extensions/mongo/CollectionTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/mongo/Collection.php b/extensions/mongo/Collection.php index e92480b..64242c1 100644 --- a/extensions/mongo/Collection.php +++ b/extensions/mongo/Collection.php @@ -165,7 +165,7 @@ class Collection extends Object try { $result = $this->mongoCollection->deleteIndexes(); $this->tryResultError($result); - return $result['nIndexesWas'] - 1; + return $result['nIndexesWas']; } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); throw new Exception($e->getMessage(), (int)$e->getCode(), $e); diff --git a/tests/unit/extensions/mongo/CollectionTest.php b/tests/unit/extensions/mongo/CollectionTest.php index 4bce0fa..bc13b2e 100644 --- a/tests/unit/extensions/mongo/CollectionTest.php +++ b/tests/unit/extensions/mongo/CollectionTest.php @@ -270,7 +270,7 @@ class CollectionTest extends MongoTestCase { $collection = $this->getConnection()->getCollection('customer'); $collection->createIndex('name'); - $this->assertEquals(1, $collection->dropAllIndexes()); + $this->assertEquals(2, $collection->dropAllIndexes()); $indexInfo = $collection->mongoCollection->getIndexInfo(); $this->assertEquals(1, count($indexInfo)); }