Example #1
0
 /**
  * Count number of records in a collection
  *
  * ``` php
  * <?php
  * $I->seeNumElementsInCollection('users', 2);
  * $I->seeNumElementsInCollection('users', 1, array('name' => 'miles'));
  * ```
  *
  * @param $collection
  * @param integer $expected
  * @param array $criteria
  */
 public function seeNumElementsInCollection($collection, $expected, $criteria = [])
 {
     $collection = $this->driver->getDbh()->selectCollection($collection);
     $res = $collection->count($criteria);
     \PHPUnit_Framework_Assert::assertSame($expected, $res);
 }
Example #2
0
 /**
  * Grabs a data from collection
  *
  * ``` php
  * <?php
  * $cursor = $I->grabFromCollection('users', array('name' => 'miles'));
  * ```
  *
  * @param $collection
  * @param array $criteria
  * @return \MongoCursor
  */
 public function grabFromCollection($collection, $criteria = array())
 {
     $collection = $this->driver->getDbh()->selectCollection($collection);
     return $collection->findOne($criteria);
 }