diff --git a/extensions/mongo/ActiveQuery.php b/extensions/mongodb/ActiveQuery.php similarity index 99% rename from extensions/mongo/ActiveQuery.php rename to extensions/mongodb/ActiveQuery.php index fc02df9..6b87533 100644 --- a/extensions/mongo/ActiveQuery.php +++ b/extensions/mongodb/ActiveQuery.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; use yii\db\ActiveQueryInterface; use yii\db\ActiveQueryTrait; diff --git a/extensions/mongo/ActiveRecord.php b/extensions/mongodb/ActiveRecord.php similarity index 98% rename from extensions/mongo/ActiveRecord.php rename to extensions/mongodb/ActiveRecord.php index 86aa6d1..d2178ea 100644 --- a/extensions/mongo/ActiveRecord.php +++ b/extensions/mongodb/ActiveRecord.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; use yii\base\InvalidConfigException; use yii\base\InvalidParamException; @@ -25,13 +25,13 @@ abstract class ActiveRecord extends BaseActiveRecord { /** * Returns the Mongo connection used by this AR class. - * By default, the "mongo" application component is used as the Mongo connection. + * By default, the "mongodb" application component is used as the Mongo connection. * You may override this method if you want to use a different database connection. * @return Connection the database connection used by this AR class. */ public static function getDb() { - return \Yii::$app->getComponent('mongo'); + return \Yii::$app->getComponent('mongodb'); } /** @@ -174,7 +174,7 @@ abstract class ActiveRecord extends BaseActiveRecord */ public function attributes() { - throw new InvalidConfigException('The attributes() method of mongo ActiveRecord has to be implemented by child classes.'); + throw new InvalidConfigException('The attributes() method of mongodb ActiveRecord has to be implemented by child classes.'); } /** diff --git a/extensions/mongo/ActiveRelation.php b/extensions/mongodb/ActiveRelation.php similarity index 95% rename from extensions/mongo/ActiveRelation.php rename to extensions/mongodb/ActiveRelation.php index 539dc7b..d4541cc 100644 --- a/extensions/mongo/ActiveRelation.php +++ b/extensions/mongodb/ActiveRelation.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; use yii\db\ActiveRelationInterface; use yii\db\ActiveRelationTrait; diff --git a/extensions/mongo/Collection.php b/extensions/mongodb/Collection.php similarity index 99% rename from extensions/mongo/Collection.php rename to extensions/mongodb/Collection.php index 9bd8bcc..f90298d 100644 --- a/extensions/mongo/Collection.php +++ b/extensions/mongodb/Collection.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; use yii\base\InvalidParamException; use yii\base\Object; diff --git a/extensions/mongo/Connection.php b/extensions/mongodb/Connection.php similarity index 97% rename from extensions/mongo/Connection.php rename to extensions/mongodb/Connection.php index 3b9ea9e..175667e 100644 --- a/extensions/mongo/Connection.php +++ b/extensions/mongodb/Connection.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; use yii\base\Component; use yii\base\InvalidConfigException; @@ -23,7 +23,7 @@ use Yii; * the DB connection: * * ~~~ - * $connection = new \yii\mongo\Connection([ + * $connection = new \yii\mongodb\Connection([ * 'dsn' => $dsn, * ]); * $connection->open(); @@ -55,8 +55,8 @@ use Yii; * ~~~ * [ * 'components' => [ - * 'mongo' => [ - * 'class' => '\yii\mongo\Connection', + * 'mongodb' => [ + * 'class' => '\yii\mongodb\Connection', * 'dsn' => 'mongodb://developer:password@localhost:27017/mydatabase', * ], * ], @@ -102,7 +102,7 @@ class Connection extends Component */ public $defaultDatabaseName; /** - * @var \MongoClient mongo client instance. + * @var \MongoClient Mongo client instance. */ public $mongoClient; /** @@ -156,7 +156,7 @@ class Connection extends Component { $this->open(); return Yii::createObject([ - 'class' => 'yii\mongo\Database', + 'class' => 'yii\mongodb\Database', 'mongoDb' => $this->mongoClient->selectDB($name) ]); } diff --git a/extensions/mongo/Database.php b/extensions/mongodb/Database.php similarity index 94% rename from extensions/mongo/Database.php rename to extensions/mongodb/Database.php index bb919b5..3606afa 100644 --- a/extensions/mongo/Database.php +++ b/extensions/mongodb/Database.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; use yii\base\Object; use Yii; @@ -46,7 +46,7 @@ class Database extends Object * Returns the Mongo collection with the given name. * @param string $name collection name * @param boolean $refresh whether to reload the collection instance even if it is found in the cache. - * @return Collection mongo collection instance. + * @return Collection Mongo collection instance. */ public function getCollection($name, $refresh = false) { @@ -60,7 +60,7 @@ class Database extends Object * Returns Mongo GridFS collection with given prefix. * @param string $prefix collection prefix. * @param boolean $refresh whether to reload the collection instance even if it is found in the cache. - * @return file\Collection mongo GridFS collection. + * @return file\Collection Mongo GridFS collection. */ public function getFileCollection($prefix = 'fs', $refresh = false) { @@ -78,7 +78,7 @@ class Database extends Object protected function selectCollection($name) { return Yii::createObject([ - 'class' => 'yii\mongo\Collection', + 'class' => 'yii\mongodb\Collection', 'mongoCollection' => $this->mongoDb->selectCollection($name) ]); } @@ -91,7 +91,7 @@ class Database extends Object protected function selectFileCollection($prefix) { return Yii::createObject([ - 'class' => 'yii\mongo\file\Collection', + 'class' => 'yii\mongodb\file\Collection', 'mongoCollection' => $this->mongoDb->getGridFS($prefix) ]); } @@ -103,7 +103,7 @@ class Database extends Object * you need to create collection with the specific options. * @param string $name name of the collection * @param array $options collection options in format: "name" => "value" - * @return \MongoCollection new mongo collection instance. + * @return \MongoCollection new Mongo collection instance. * @throws Exception on failure. */ public function createCollection($name, $options = []) diff --git a/extensions/mongo/Exception.php b/extensions/mongodb/Exception.php similarity index 95% rename from extensions/mongo/Exception.php rename to extensions/mongodb/Exception.php index 0687e48..3288167 100644 --- a/extensions/mongo/Exception.php +++ b/extensions/mongodb/Exception.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; /** * Exception represents an exception that is caused by some Mongo-related operations. diff --git a/extensions/mongo/LICENSE.md b/extensions/mongodb/LICENSE.md similarity index 100% rename from extensions/mongo/LICENSE.md rename to extensions/mongodb/LICENSE.md diff --git a/extensions/mongo/Query.php b/extensions/mongodb/Query.php similarity index 92% rename from extensions/mongo/Query.php rename to extensions/mongodb/Query.php index cce6645..28e123c 100644 --- a/extensions/mongo/Query.php +++ b/extensions/mongodb/Query.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo; +namespace yii\mongodb; use yii\base\Component; use yii\db\QueryInterface; @@ -60,7 +60,7 @@ class Query extends Component implements QueryInterface public function getCollection($db = null) { if ($db === null) { - $db = Yii::$app->getComponent('mongo'); + $db = Yii::$app->getComponent('mongodb'); } return $db->getCollection($this->from); } @@ -180,7 +180,7 @@ class Query extends Component implements QueryInterface /** * Executes the query and returns all results as an array. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return array the query results. If the query results in nothing, an empty array will be returned. */ public function all($db = null) @@ -192,7 +192,7 @@ class Query extends Component implements QueryInterface /** * Executes the query and returns a single row of result. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return array|boolean the first row (in terms of an array) of the query result. False is returned if the query * results in nothing. */ @@ -206,7 +206,7 @@ class Query extends Component implements QueryInterface * Returns the number of records. * @param string $q kept to match [[QueryInterface]], its value is ignored. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return integer number of records * @throws Exception on failure. */ @@ -229,7 +229,7 @@ class Query extends Component implements QueryInterface /** * Returns a value indicating whether the query result contains any row of data. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return boolean whether the query result contains any row of data. */ public function exists($db = null) @@ -242,7 +242,7 @@ class Query extends Component implements QueryInterface * @param string $q the column name. * Make sure you properly quote column names in the expression. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return integer the sum of the specified column values */ public function sum($q, $db = null) @@ -255,7 +255,7 @@ class Query extends Component implements QueryInterface * @param string $q the column name. * Make sure you properly quote column names in the expression. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return integer the average of the specified column values. */ public function average($q, $db = null) @@ -281,7 +281,7 @@ class Query extends Component implements QueryInterface * @param string $q the column name. * Make sure you properly quote column names in the expression. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return integer the maximum of the specified column values. */ public function max($q, $db = null) @@ -323,7 +323,7 @@ class Query extends Component implements QueryInterface * Returns a list of distinct values for the given column across a collection. * @param string $q column to use. * @param Connection $db the Mongo connection used to execute the query. - * If this parameter is not given, the `mongo` application component will be used. + * If this parameter is not given, the `mongodb` application component will be used. * @return array array of distinct values */ public function distinct($q, $db = null) diff --git a/extensions/mongo/README.md b/extensions/mongodb/README.md similarity index 89% rename from extensions/mongo/README.md rename to extensions/mongodb/README.md index 7f5ef70..85c1a96 100644 --- a/extensions/mongo/README.md +++ b/extensions/mongodb/README.md @@ -21,12 +21,12 @@ The preferred way to install this extension is through [composer](http://getcomp Either run ``` -php composer.phar require yiisoft/yii2-mongo "*" +php composer.phar require yiisoft/yii2-mongodb "*" ``` or add ``` -"yiisoft/yii2-mongo": "*" +"yiisoft/yii2-mongodb": "*" ``` to the require section of your composer.json. @@ -47,8 +47,8 @@ To use this extension, simply add the following code in your application configu return [ //.... 'components' => [ - 'mongo' => [ - 'class' => '\yii\mongo\Connection', + 'mongodb' => [ + 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://developer:password@localhost:27017/mydatabase', ], ], @@ -56,11 +56,11 @@ return [ ``` This extension provides ActiveRecord solution similar ot the [[\yii\db\ActiveRecord]]. -To declare an ActiveRecord class you need to extend [[\yii\mongo\ActiveRecord]] and +To declare an ActiveRecord class you need to extend [[\yii\mongodb\ActiveRecord]] and implement the `collectionName` and 'attributes' methods: ```php -use yii\mongo\ActiveRecord; +use yii\mongodb\ActiveRecord; class Customer extends ActiveRecord { @@ -82,11 +82,11 @@ class Customer extends ActiveRecord } ``` -You can use [[\yii\data\ActiveDataProvider]] with the [[\yii\mongo\Query]] and [[\yii\mongo\ActiveQuery]]: +You can use [[\yii\data\ActiveDataProvider]] with the [[\yii\mongodb\Query]] and [[\yii\mongodb\ActiveQuery]]: ```php use yii\data\ActiveDataProvider; -use yii\mongo\Query; +use yii\mongodb\Query; $query = new Query; $query->from('customer')->where(['status' => 2]); diff --git a/extensions/mongo/composer.json b/extensions/mongodb/composer.json similarity index 86% rename from extensions/mongo/composer.json rename to extensions/mongodb/composer.json index 38296b6..fc850b2 100644 --- a/extensions/mongo/composer.json +++ b/extensions/mongodb/composer.json @@ -1,5 +1,5 @@ { - "name": "yiisoft/yii2-mongo", + "name": "yiisoft/yii2-mongodb", "description": "MongoDb extension for the Yii framework", "keywords": ["yii", "mongo", "mongodb", "active-record"], "type": "yii2-extension", @@ -22,7 +22,7 @@ "ext-mongo": ">=1.3.0" }, "autoload": { - "psr-0": { "yii\\mongo\\": "" } + "psr-0": { "yii\\mongodb\\": "" } }, - "target-dir": "yii/mongo" + "target-dir": "yii/mongodb" } diff --git a/extensions/mongo/file/ActiveQuery.php b/extensions/mongodb/file/ActiveQuery.php similarity index 93% rename from extensions/mongo/file/ActiveQuery.php rename to extensions/mongodb/file/ActiveQuery.php index 91661d6..4cdac5c 100644 --- a/extensions/mongo/file/ActiveQuery.php +++ b/extensions/mongodb/file/ActiveQuery.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo\file; +namespace yii\mongodb\file; use yii\db\ActiveQueryInterface; use yii\db\ActiveQueryTrait; @@ -38,7 +38,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface /** * Executes query and returns all results as an array. - * @param \yii\mongo\Connection $db the Mongo connection used to execute the query. + * @param \yii\mongodb\Connection $db the Mongo connection used to execute the query. * If null, the Mongo connection returned by [[modelClass]] will be used. * @return array the query results. If the query results in nothing, an empty array will be returned. */ @@ -59,7 +59,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface /** * Executes query and returns a single row of result. - * @param \yii\mongo\Connection $db the Mongo connection used to execute the query. + * @param \yii\mongodb\Connection $db the Mongo connection used to execute the query. * If null, the Mongo connection returned by [[modelClass]] will be used. * @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]], * the query result may be either an array or an ActiveRecord object. Null will be returned diff --git a/extensions/mongo/file/ActiveRecord.php b/extensions/mongodb/file/ActiveRecord.php similarity index 99% rename from extensions/mongo/file/ActiveRecord.php rename to extensions/mongodb/file/ActiveRecord.php index c7ca752..014accf 100644 --- a/extensions/mongo/file/ActiveRecord.php +++ b/extensions/mongodb/file/ActiveRecord.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo\file; +namespace yii\mongodb\file; use yii\base\InvalidParamException; use yii\db\StaleObjectException; @@ -48,7 +48,7 @@ use yii\web\UploadedFile; * @author Paul Klimov * @since 2.0 */ -abstract class ActiveRecord extends \yii\mongo\ActiveRecord +abstract class ActiveRecord extends \yii\mongodb\ActiveRecord { /** * Creates an [[ActiveQuery]] instance. diff --git a/extensions/mongo/file/ActiveRelation.php b/extensions/mongodb/file/ActiveRelation.php similarity index 94% rename from extensions/mongo/file/ActiveRelation.php rename to extensions/mongodb/file/ActiveRelation.php index 6ea0831..ea1f7e6 100644 --- a/extensions/mongo/file/ActiveRelation.php +++ b/extensions/mongodb/file/ActiveRelation.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo\file; +namespace yii\mongodb\file; use yii\db\ActiveRelationInterface; use yii\db\ActiveRelationTrait; diff --git a/extensions/mongo/file/Collection.php b/extensions/mongodb/file/Collection.php similarity index 95% rename from extensions/mongo/file/Collection.php rename to extensions/mongodb/file/Collection.php index b3c722b..064d4bc 100644 --- a/extensions/mongo/file/Collection.php +++ b/extensions/mongodb/file/Collection.php @@ -5,9 +5,9 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo\file; +namespace yii\mongodb\file; -use yii\mongo\Exception; +use yii\mongodb\Exception; use Yii; /** @@ -23,27 +23,27 @@ use Yii; * @author Paul Klimov * @since 2.0 */ -class Collection extends \yii\mongo\Collection +class Collection extends \yii\mongodb\Collection { /** * @var \MongoGridFS Mongo GridFS collection instance. */ public $mongoCollection; /** - * @var \yii\mongo\Collection file chunks Mongo collection. + * @var \yii\mongodb\Collection file chunks Mongo collection. */ private $_chunkCollection; /** * Returns the Mongo collection for the file chunks. * @param boolean $refresh whether to reload the collection instance even if it is found in the cache. - * @return \yii\mongo\Collection mongo collection instance. + * @return \yii\mongodb\Collection mongo collection instance. */ public function getChunkCollection($refresh = false) { if ($refresh || !is_object($this->_chunkCollection)) { $this->_chunkCollection = Yii::createObject([ - 'class' => 'yii\mongo\Collection', + 'class' => 'yii\mongodb\Collection', 'mongoCollection' => $this->mongoCollection->chunks ]); } diff --git a/extensions/mongo/file/Query.php b/extensions/mongodb/file/Query.php similarity index 85% rename from extensions/mongo/file/Query.php rename to extensions/mongodb/file/Query.php index c15d4f1..d49da94 100644 --- a/extensions/mongo/file/Query.php +++ b/extensions/mongodb/file/Query.php @@ -5,33 +5,31 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\mongo\file; +namespace yii\mongodb\file; use Yii; -use yii\helpers\Json; -use yii\mongo\Exception; /** * Query represents Mongo "find" operation for GridFS collection. * - * Query behaves exactly as regular [[\yii\mongo\Query]]. + * Query behaves exactly as regular [[\yii\mongodb\Query]]. * Found files will be represented as arrays of file document attributes with * additional 'file' key, which stores [[\MongoGridFSFile]] instance. * * @author Paul Klimov * @since 2.0 */ -class Query extends \yii\mongo\Query +class Query extends \yii\mongodb\Query { /** * Returns the Mongo collection for this query. - * @param \yii\mongo\Connection $db Mongo connection. + * @param \yii\mongodb\Connection $db Mongo connection. * @return Collection collection instance. */ public function getCollection($db = null) { if ($db === null) { - $db = Yii::$app->getComponent('mongo'); + $db = Yii::$app->getComponent('mongodb'); } return $db->getFileCollection($this->from); } diff --git a/tests/unit/data/ar/mongo/ActiveRecord.php b/tests/unit/data/ar/mongodb/ActiveRecord.php similarity index 58% rename from tests/unit/data/ar/mongo/ActiveRecord.php rename to tests/unit/data/ar/mongodb/ActiveRecord.php index 6f5bc49..b0709a8 100644 --- a/tests/unit/data/ar/mongo/ActiveRecord.php +++ b/tests/unit/data/ar/mongodb/ActiveRecord.php @@ -1,11 +1,11 @@ __DIR__ . '/sphinx/source.sql', ], ], - 'mongo' => [ + 'mongodb' => [ 'dsn' => 'mongodb://travis:test@localhost:27017', 'defaultDatabaseName' => 'yii2test', 'options' => [], diff --git a/tests/unit/extensions/mongo/ActiveDataProviderTest.php b/tests/unit/extensions/mongodb/ActiveDataProviderTest.php similarity index 89% rename from tests/unit/extensions/mongo/ActiveDataProviderTest.php rename to tests/unit/extensions/mongodb/ActiveDataProviderTest.php index 3660516..350769d 100644 --- a/tests/unit/extensions/mongo/ActiveDataProviderTest.php +++ b/tests/unit/extensions/mongodb/ActiveDataProviderTest.php @@ -1,16 +1,16 @@ getConnection()->getCollection($collectionName); $this->assertEquals($collectionName, $collection->getName()); - $this->assertEquals($this->mongoConfig['defaultDatabaseName'] . '.' . $collectionName, $collection->getFullName()); + $this->assertEquals($this->mongoDbConfig['defaultDatabaseName'] . '.' . $collectionName, $collection->getFullName()); } public function testFind() @@ -264,7 +264,7 @@ class CollectionTest extends MongoTestCase $indexInfo = $collection->mongoCollection->getIndexInfo(); $this->assertEquals(1, count($indexInfo)); - $this->setExpectedException('\yii\mongo\Exception'); + $this->setExpectedException('\yii\mongodb\Exception'); $collection->dropIndex('name'); } diff --git a/tests/unit/extensions/mongo/ConnectionTest.php b/tests/unit/extensions/mongodb/ConnectionTest.php similarity index 81% rename from tests/unit/extensions/mongo/ConnectionTest.php rename to tests/unit/extensions/mongodb/ConnectionTest.php index 04d5351..e96acab 100644 --- a/tests/unit/extensions/mongo/ConnectionTest.php +++ b/tests/unit/extensions/mongodb/ConnectionTest.php @@ -1,21 +1,21 @@ getConnection(false); - $params = $this->mongoConfig; + $params = $this->mongoDbConfig; $connection->open(); @@ -41,7 +41,7 @@ class ConnectionTest extends MongoTestCase $connection = new Connection; $connection->dsn = 'unknown::memory:'; - $this->setExpectedException('yii\mongo\Exception'); + $this->setExpectedException('yii\mongodb\Exception'); $connection->open(); } @@ -66,19 +66,19 @@ class ConnectionTest extends MongoTestCase public function testGetDefaultDatabase() { $connection = new Connection(); - $connection->dsn = $this->mongoConfig['dsn']; - $connection->defaultDatabaseName = $this->mongoConfig['defaultDatabaseName']; + $connection->dsn = $this->mongoDbConfig['dsn']; + $connection->defaultDatabaseName = $this->mongoDbConfig['defaultDatabaseName']; $database = $connection->getDatabase(); $this->assertTrue($database instanceof Database, 'Unable to get default database!'); $connection = new Connection(); - $connection->dsn = $this->mongoConfig['dsn']; - $connection->options = ['db' => $this->mongoConfig['defaultDatabaseName']]; + $connection->dsn = $this->mongoDbConfig['dsn']; + $connection->options = ['db' => $this->mongoDbConfig['defaultDatabaseName']]; $database = $connection->getDatabase(); $this->assertTrue($database instanceof Database, 'Unable to determine default database from options!'); $connection = new Connection(); - $connection->dsn = $this->mongoConfig['dsn'] . '/' . $this->mongoConfig['defaultDatabaseName']; + $connection->dsn = $this->mongoDbConfig['dsn'] . '/' . $this->mongoDbConfig['defaultDatabaseName']; $database = $connection->getDatabase(); $this->assertTrue($database instanceof Database, 'Unable to determine default database from dsn!'); } diff --git a/tests/unit/extensions/mongo/DatabaseTest.php b/tests/unit/extensions/mongodb/DatabaseTest.php similarity index 91% rename from tests/unit/extensions/mongo/DatabaseTest.php rename to tests/unit/extensions/mongodb/DatabaseTest.php index 6847d2e..10b6f14 100644 --- a/tests/unit/extensions/mongo/DatabaseTest.php +++ b/tests/unit/extensions/mongodb/DatabaseTest.php @@ -1,14 +1,14 @@ 'mongodb://localhost:27017', 'defaultDatabaseName' => 'yii2test', 'options' => [], @@ -21,7 +21,7 @@ class MongoTestCase extends TestCase /** * @var Connection Mongo connection instance. */ - protected $mongo; + protected $mongodb; public static function setUpBeforeClass() { @@ -34,9 +34,9 @@ class MongoTestCase extends TestCase if (!extension_loaded('mongo')) { $this->markTestSkipped('mongo extension required.'); } - $config = $this->getParam('mongo'); + $config = $this->getParam('mongodb'); if (!empty($config)) { - $this->mongoConfig = $config; + $this->mongoDbConfig = $config; } $this->mockApplication(); static::loadClassMap(); @@ -44,8 +44,8 @@ class MongoTestCase extends TestCase protected function tearDown() { - if ($this->mongo) { - $this->mongo->close(); + if ($this->mongodb) { + $this->mongodb->close(); } $this->destroyApplication(); } @@ -56,8 +56,8 @@ class MongoTestCase extends TestCase */ protected static function loadClassMap() { - $baseNameSpace = 'yii/mongo'; - $basePath = realpath(__DIR__. '/../../../../extensions/mongo'); + $baseNameSpace = 'yii/mongodb'; + $basePath = realpath(__DIR__. '/../../../../extensions/mongodb'); $files = FileHelper::findFiles($basePath); foreach ($files as $file) { $classRelativePath = str_replace($basePath, '', $file); @@ -69,23 +69,23 @@ class MongoTestCase extends TestCase /** * @param boolean $reset whether to clean up the test database * @param boolean $open whether to open test database - * @return \yii\mongo\Connection + * @return \yii\mongodb\Connection */ public function getConnection($reset = false, $open = true) { - if (!$reset && $this->mongo) { - return $this->mongo; + if (!$reset && $this->mongodb) { + return $this->mongodb; } $db = new Connection; - $db->dsn = $this->mongoConfig['dsn']; - $db->defaultDatabaseName = $this->mongoConfig['defaultDatabaseName']; - if (isset($this->mongoConfig['options'])) { - $db->options = $this->mongoConfig['options']; + $db->dsn = $this->mongoDbConfig['dsn']; + $db->defaultDatabaseName = $this->mongoDbConfig['defaultDatabaseName']; + if (isset($this->mongoDbConfig['options'])) { + $db->options = $this->mongoDbConfig['options']; } if ($open) { $db->open(); } - $this->mongo = $db; + $this->mongodb = $db; return $db; } @@ -95,9 +95,9 @@ class MongoTestCase extends TestCase */ protected function dropCollection($name) { - if ($this->mongo) { + if ($this->mongodb) { try { - $this->mongo->getCollection($name)->drop(); + $this->mongodb->getCollection($name)->drop(); } catch (Exception $e) { // shut down exception } @@ -110,9 +110,9 @@ class MongoTestCase extends TestCase */ protected function dropFileCollection($name = 'fs') { - if ($this->mongo) { + if ($this->mongodb) { try { - $this->mongo->getFileCollection($name)->drop(); + $this->mongodb->getFileCollection($name)->drop(); } catch (Exception $e) { // shut down exception } @@ -121,7 +121,7 @@ class MongoTestCase extends TestCase /** * Finds all records in collection. - * @param \yii\mongo\Collection $collection + * @param \yii\mongodb\Collection $collection * @param array $condition * @param array $fields * @return array rows diff --git a/tests/unit/extensions/mongo/QueryRunTest.php b/tests/unit/extensions/mongodb/QueryRunTest.php similarity index 96% rename from tests/unit/extensions/mongo/QueryRunTest.php rename to tests/unit/extensions/mongodb/QueryRunTest.php index 121e826..c295ac8 100644 --- a/tests/unit/extensions/mongo/QueryRunTest.php +++ b/tests/unit/extensions/mongodb/QueryRunTest.php @@ -1,13 +1,13 @@ getConnection()->getFileCollection(); $chunkCollection = $collection->getChunkCollection(); - $this->assertTrue($chunkCollection instanceof \yii\mongo\Collection); + $this->assertTrue($chunkCollection instanceof \yii\mongodb\Collection); $this->assertTrue($chunkCollection->mongoCollection instanceof \MongoCollection); } diff --git a/tests/unit/extensions/mongo/file/QueryTest.php b/tests/unit/extensions/mongodb/file/QueryTest.php similarity index 88% rename from tests/unit/extensions/mongo/file/QueryTest.php rename to tests/unit/extensions/mongodb/file/QueryTest.php index 2f9ec67..c5a0c4f 100644 --- a/tests/unit/extensions/mongo/file/QueryTest.php +++ b/tests/unit/extensions/mongodb/file/QueryTest.php @@ -1,14 +1,14 @@