Skip to content

Commit 7115506

Browse files
github-actions[bot]github-actions[bot]
authored andcommitted
updated
1 parent 7e93bd6 commit 7115506

File tree

2 files changed

+93
-8
lines changed

2 files changed

+93
-8
lines changed

changelog.markdown

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ title: Codeception Changelog
99

1010

1111

12+
### module-db 3.1.0: 3.1.0
13+
14+
Released by [![](https://avatars.githubusercontent.com/u/395992?v=4&s=16) Naktibalda](https://github.com/Naktibalda) on 2022/12/03 10:23:12 / [Repository](https://github.com/Codeception/module-db) / [Releases](https://github.com/Codeception/module-db/releases)
15+
16+
17+
18+
* Implemented `grabEntryFromDatabase` and `grabEntriesFromDatabase` methods by **[JesusTheHun](https://github.com/JesusTheHun)** in https://github.com/Codeception/module-db/pull/43
19+
* Improved handling of auto_increment field in `haveInDatabase` tear down by **[JesusTheHun](https://github.com/JesusTheHun)** in https://github.com/Codeception/module-db/pull/44
20+
* Add docker elements to ease local testing by **[JesusTheHun](https://github.com/JesusTheHun)** in https://github.com/Codeception/module-db/pull/42
21+
22+
23+
24+
### module-db 2.1.0: 2.1.0
25+
26+
Released by [![](https://avatars.githubusercontent.com/u/395992?v=4&s=16) Naktibalda](https://github.com/Naktibalda) on 2022/12/03 10:22:30 / [Repository](https://github.com/Codeception/module-db) / [Releases](https://github.com/Codeception/module-db/releases)
27+
28+
29+
30+
* Implemented `grabEntryFromDatabase` and `grabEntriesFromDatabase` methods by **[JesusTheHun](https://github.com/JesusTheHun)** in https://github.com/Codeception/module-db/pull/43
31+
* Improved handling of auto_increment field in `haveInDatabase` tear down by **[JesusTheHun](https://github.com/JesusTheHun)** in https://github.com/Codeception/module-db/pull/44
32+
* Add docker elements to ease local testing by **[JesusTheHun](https://github.com/JesusTheHun)** in https://github.com/Codeception/module-db/pull/42
33+
34+
35+
1236
### Codeception 5.0.5: 5.0.5
1337

1438
Released by [![](https://avatars.githubusercontent.com/u/395992?v=4&s=16) Naktibalda](https://github.com/Naktibalda) on 2022/11/20 11:33:41 / [Repository](https://github.com/Codeception/Codeception) / [Releases](https://github.com/Codeception/Codeception/releases)

docs/modules/Db.md

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Warning. Using PHAR file and composer in the same project can cause unexpected e
3535
Access a database.
3636

3737
The most important function of this module is to clean a database before each test.
38-
This module also provides actions to perform checks in a database, e.g. [seeInDatabase()](http://codeception.com/docs/modules/Db#seeInDatabase)
38+
This module also provides actions to perform checks in a database, e.g. [seeInDatabase()](https://codeception.com/docs/modules/Db#seeInDatabase)
3939

4040
In order to have your database populated with data you need a raw SQL dump.
4141
Simply put the dump in the `tests/_data` directory (by default) and specify the path in the config.
@@ -67,11 +67,11 @@ if you run into problems loading dumps and cleaning databases.
6767
* cleanup: false - whether the dump should be reloaded before each test
6868
* reconnect: false - whether the module should reconnect to the database before each test
6969
* waitlock: 0 - wait lock (in seconds) that the database session should use for DDL statements
70-
* ssl_key - path to the SSL key (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key)
71-
* ssl_cert - path to the SSL certificate (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert)
72-
* ssl_ca - path to the SSL certificate authority (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca)
73-
* ssl_verify_server_cert - disables certificate CN verification (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php)
74-
* ssl_cipher - list of one or more permissible ciphers to use for SSL encryption (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-cipher)
70+
* ssl_key - path to the SSL key (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key)
71+
* ssl_cert - path to the SSL certificate (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert)
72+
* ssl_ca - path to the SSL certificate authority (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca)
73+
* ssl_verify_server_cert - disables certificate CN verification (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php)
74+
* ssl_cipher - list of one or more permissible ciphers to use for SSL encryption (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-cipher)
7575
* databases - include more database configs and switch between them in tests.
7676
* initial_queries - list of queries to be executed right after connection to the database has been initiated, i.e. creating the database if it does not exist or preparing the database collation
7777
* skip_cleanup_if_failed - Do not perform the cleanup if the tests failed. If this is used, manual cleanup might be required when re-running
@@ -352,6 +352,67 @@ $mails = $I->grabColumnFromDatabase('users', 'email', array('name' => 'RebOOter'
352352
{% endhighlight %}
353353

354354

355+
#### grabEntriesFromDatabase
356+
357+
* `param string` $table
358+
* `param array` $criteria
359+
* `throws PDOException|Exception`
360+
* `return array<array<string,` mixed>> Returns an array of all matched rows
361+
362+
Fetches a set of entries from a database.
363+
364+
Provide table name and criteria.
365+
366+
{% highlight php %}
367+
368+
<?php
369+
$mail = $I->grabEntriesFromDatabase('users', array('name' => 'Davert'));
370+
371+
{% endhighlight %}
372+
Comparison expressions can be used as well:
373+
374+
{% highlight php %}
375+
376+
<?php
377+
$post = $I->grabEntriesFromDatabase('posts', ['num_comments >=' => 100]);
378+
$user = $I->grabEntriesFromDatabase('users', ['email like' => 'miles%']);
379+
380+
{% endhighlight %}
381+
382+
Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
383+
384+
385+
#### grabEntryFromDatabase
386+
387+
* `param string` $table
388+
* `param array` $criteria
389+
* `throws PDOException|Exception`
390+
* `return array` Returns a single entry value
391+
392+
Fetches a whole entry from a database.
393+
394+
Make the test fail if the entry is not found.
395+
Provide table name, desired column and criteria.
396+
397+
{% highlight php %}
398+
399+
<?php
400+
$mail = $I->grabEntryFromDatabase('users', array('name' => 'Davert'));
401+
402+
{% endhighlight %}
403+
Comparison expressions can be used as well:
404+
405+
{% highlight php %}
406+
407+
<?php
408+
$post = $I->grabEntryFromDatabase('posts', ['num_comments >=' => 100]);
409+
$user = $I->grabEntryFromDatabase('users', ['email like' => 'miles%']);
410+
411+
{% endhighlight %}
412+
413+
Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
414+
415+
355416
#### grabFromDatabase
356417

357418
* `param string` $table
@@ -374,8 +435,8 @@ Comparison expressions can be used as well:
374435
{% highlight php %}
375436

376437
<?php
377-
$post = $I->grabFromDatabase('posts', ['num_comments >=' => 100]);
378-
$user = $I->grabFromDatabase('users', ['email like' => 'miles%']);
438+
$postNum = $I->grabFromDatabase('posts', 'num_comments', ['num_comments >=' => 100]);
439+
$mail = $I->grabFromDatabase('users', 'email', ['email like' => 'miles%']);
379440

380441
{% endhighlight %}
381442

0 commit comments

Comments
 (0)