@@ -96,10 +96,11 @@ class MongoDb extends Module implements RequiresPackage
9696 protected $ config = [
9797 'populate ' => true ,
9898 'cleanup ' => true ,
99+ 'dsn ' => '' ,
99100 'dump ' => null ,
100101 'dump_type ' => self ::DUMP_TYPE_JS ,
101- 'user ' => null ,
102- 'password ' => null ,
102+ 'user ' => '' ,
103+ 'password ' => '' ,
103104 'quiet ' => false ,
104105 ];
105106
@@ -120,7 +121,6 @@ class MongoDb extends Module implements RequiresPackage
120121
121122 public function _initialize ()
122123 {
123-
124124 try {
125125 $ this ->driver = MongoDbDriver::create (
126126 $ this ->config ['dsn ' ],
@@ -280,37 +280,34 @@ protected function loadDump(): void
280280 /**
281281 * Specify the database to use
282282 *
283- * ``` php
283+ * ```php
284284 * <?php
285285 * $I->useDatabase('db_1');
286286 * ```
287287 *
288- * @param $dbName
288+ * @param string $dbName
289289 */
290- public function useDatabase ($ dbName ): void
290+ public function useDatabase (string $ dbName ): void
291291 {
292292 $ this ->driver ->setDatabase ($ dbName );
293293 }
294294
295295 /**
296296 * Inserts data into collection
297297 *
298- * ``` php
298+ * ```php
299299 * <?php
300300 * $I->haveInCollection('users', ['name' => 'John', 'email' => 'john@coltrane.com']);
301301 * $user_id = $I->haveInCollection('users', ['email' => 'john@coltrane.com']);
302302 * ```
303303 *
304- * @param $collection
305- * @return mixed|string
304+ * @param string $collection
305+ * @param array $data
306+ * @return string
306307 */
307- public function haveInCollection ($ collection , array $ data )
308+ public function haveInCollection (string $ collection , array $ data ): string
308309 {
309310 $ collection = $ this ->driver ->getDbh ()->selectCollection ($ collection );
310- if ($ this ->driver ->isLegacy ()) {
311- $ collection ->insert ($ data );
312- return $ data ['_id ' ];
313- }
314311
315312 $ response = $ collection ->insertOne ($ data );
316313 return (string ) $ response ->getInsertedId ();
@@ -319,14 +316,14 @@ public function haveInCollection($collection, array $data)
319316 /**
320317 * Checks if collection contains an item.
321318 *
322- * ``` php
319+ * ```php
323320 * <?php
324321 * $I->seeInCollection('users', ['name' => 'miles']);
325322 * ```
326323 *
327- * @param $collection
324+ * @param string $collection
328325 */
329- public function seeInCollection ($ collection , array $ criteria = []): void
326+ public function seeInCollection (string $ collection , array $ criteria = []): void
330327 {
331328 $ collection = $ this ->driver ->getDbh ()->selectCollection ($ collection );
332329 $ res = $ collection ->count ($ criteria );
@@ -336,14 +333,14 @@ public function seeInCollection($collection, array $criteria = []): void
336333 /**
337334 * Checks if collection doesn't contain an item.
338335 *
339- * ``` php
336+ * ```php
340337 * <?php
341338 * $I->dontSeeInCollection('users', ['name' => 'miles']);
342339 * ```
343340 *
344- * @param $collection
341+ * @param string $collection
345342 */
346- public function dontSeeInCollection ($ collection , array $ criteria = []): void
343+ public function dontSeeInCollection (string $ collection , array $ criteria = []): void
347344 {
348345 $ collection = $ this ->driver ->getDbh ()->selectCollection ($ collection );
349346 $ res = $ collection ->count ($ criteria );
@@ -353,15 +350,15 @@ public function dontSeeInCollection($collection, array $criteria = []): void
353350 /**
354351 * Grabs a data from collection
355352 *
356- * ``` php
353+ * ```php
357354 * <?php
358355 * $user = $I->grabFromCollection('users', ['name' => 'miles']);
359356 * ```
360357 *
361- * @param $collection
358+ * @param string $collection
362359 * @return \MongoDB\Model\BSONDocument|mixed
363360 */
364- public function grabFromCollection ($ collection , array $ criteria = [])
361+ public function grabFromCollection (string $ collection , array $ criteria = [])
365362 {
366363 $ collection = $ this ->driver ->getDbh ()->selectCollection ($ collection );
367364 return $ collection ->findOne ($ criteria );
@@ -370,16 +367,16 @@ public function grabFromCollection($collection, array $criteria = [])
370367 /**
371368 * Grabs the documents count from a collection
372369 *
373- * ``` php
370+ * ```php
374371 * <?php
375372 * $count = $I->grabCollectionCount('users');
376373 * // or
377374 * $count = $I->grabCollectionCount('users', ['isAdmin' => true]);
378375 * ```
379376 *
380- * @param $collection
377+ * @param string $collection
381378 */
382- public function grabCollectionCount ($ collection , array $ criteria = []): int
379+ public function grabCollectionCount (string $ collection , array $ criteria = []): int
383380 {
384381 $ collection = $ this ->driver ->getDbh ()->selectCollection ($ collection );
385382 return $ collection ->count ($ criteria );
@@ -388,7 +385,7 @@ public function grabCollectionCount($collection, array $criteria = []): int
388385 /**
389386 * Asserts that an element in a collection exists and is an Array
390387 *
391- * ``` php
388+ * ```php
392389 * <?php
393390 * $I->seeElementIsArray('users', ['name' => 'John Doe'], 'data.skills');
394391 * ```
@@ -417,7 +414,7 @@ public function seeElementIsArray(string $collection, array $criteria = [], stri
417414 /**
418415 * Asserts that an element in a collection exists and is an Object
419416 *
420- * ``` php
417+ * ```php
421418 * <?php
422419 * $I->seeElementIsObject('users', ['name' => 'John Doe'], 'data');
423420 * ```
@@ -446,15 +443,15 @@ public function seeElementIsObject(string $collection, array $criteria = [], str
446443 /**
447444 * Count number of records in a collection
448445 *
449- * ``` php
446+ * ```php
450447 * <?php
451448 * $I->seeNumElementsInCollection('users', 2);
452449 * $I->seeNumElementsInCollection('users', 1, ['name' => 'miles']);
453450 * ```
454451 *
455- * @param $collection
452+ * @param string $collection
456453 */
457- public function seeNumElementsInCollection ($ collection , int $ expected , array $ criteria = []): void
454+ public function seeNumElementsInCollection (string $ collection , int $ expected , array $ criteria = []): void
458455 {
459456 $ collection = $ this ->driver ->getDbh ()->selectCollection ($ collection );
460457 $ res = $ collection ->count ($ criteria );
0 commit comments