Browse Source

Mongo Collection "deleteAllIndexes" return result fixed.

tags/2.0.0-beta
Paul Klimov 11 years ago
parent
commit
1a9d5a11ff
  1. 2
      extensions/mongo/Collection.php
  2. 2
      tests/unit/extensions/mongo/CollectionTest.php

2
extensions/mongo/Collection.php

@ -165,7 +165,7 @@ class Collection extends Object
try { try {
$result = $this->mongoCollection->deleteIndexes(); $result = $this->mongoCollection->deleteIndexes();
$this->tryResultError($result); $this->tryResultError($result);
return $result['nIndexesWas'] - 1; return $result['nIndexesWas'];
} catch (\Exception $e) { } catch (\Exception $e) {
Yii::endProfile($token, __METHOD__); Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), (int)$e->getCode(), $e); throw new Exception($e->getMessage(), (int)$e->getCode(), $e);

2
tests/unit/extensions/mongo/CollectionTest.php

@ -270,7 +270,7 @@ class CollectionTest extends MongoTestCase
{ {
$collection = $this->getConnection()->getCollection('customer'); $collection = $this->getConnection()->getCollection('customer');
$collection->createIndex('name'); $collection->createIndex('name');
$this->assertEquals(1, $collection->dropAllIndexes()); $this->assertEquals(2, $collection->dropAllIndexes());
$indexInfo = $collection->mongoCollection->getIndexInfo(); $indexInfo = $collection->mongoCollection->getIndexInfo();
$this->assertEquals(1, count($indexInfo)); $this->assertEquals(1, count($indexInfo));
} }

Loading…
Cancel
Save