| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
| layout | doc |
|---|---|
| title | MongoDb Module - Codeception - Documentation |
For additional reference, please review the source
Works with MongoDb database.
The most important function of this module is cleaning database before each test. To have your database properly cleaned you should configure it to access the database.
In order to have your database populated with data you need a valid js file with data (of the same style which can be fed up to mongo binary) File can be generated by RockMongo export command Just put it in {% highlight yaml %} tests/_data {% endhighlight %} dir (by default) and specify path to it in config. Next time after database is cleared all your data will be restored from dump. The DB preparation should as following:
Connection is done by MongoDb driver, which is stored in Codeception\Lib\Driver namespace. Check out the driver if you get problems loading dumps and cleaning databases.
Please review the code of non-stable modules and provide patches if you have issues.
Checks if collection doesn't contain an item.
{% highlight php %}
dontSeeInCollection('users', array('name' => 'miles')); {% endhighlight %} * `param` $collection * `param array` $criteria #### grabFromCollection Grabs a data from collection {% highlight php %} grabFromCollection('users', array('name' => 'miles')); {% endhighlight %} * `param` $collection * `param array` $criteria @return \MongoCursor #### haveInCollection Inserts data into collection {% highlight php %} $I->haveInCollection('users', array('name' => 'John', 'email' => 'john@coltrane.com')); $user_id = $I->haveInCollection('users', array('email' => 'john@coltrane.com')); {% endhighlight %} * `param` $collection * `param array` $data #### seeInCollection Checks if collection contains an item. {% highlight php %} seeInCollection('users', array('name' => 'miles')); {% endhighlight %} * `param` $collection * `param array` $criteria| Back | FazBrowse Home | New Git URL |