Skip to content

Commit 2fe8a82

Browse files
github-actions[bot]github-actions[bot]
github-actions[bot]
authored and
github-actions[bot]
committed
updated
1 parent 3515bba commit 2fe8a82

File tree

2 files changed

+116
-97
lines changed

2 files changed

+116
-97
lines changed

changelog.markdown

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

1010

1111

12+
### module-db 3.2.0: 3.2.0
13+
14+
Released by [![](https://avatars.githubusercontent.com/u/4129631?v=4&s=16) szhajdu](https://github.com/szhajdu) on 2025/01/31 22:25:44 / [Repository](https://github.com/Codeception/module-db) / [Releases](https://github.com/Codeception/module-db/releases)
15+
16+
17+
18+
## What's Changed
19+
* test: Run test against PHP 8.3 by **[szhajdu](https://github.com/szhajdu)** in https://github.com/Codeception/module-db/pull/71
20+
* docs: Use short array syntax for consistency by **[W0rma](https://github.com/W0rma)** in https://github.com/Codeception/module-db/pull/72
21+
* feat: Configure nullable types explicitly by **[W0rma](https://github.com/W0rma)** in https://github.com/Codeception/module-db/pull/73
22+
* test: /opt/mssql-tools/bin/sqlcmd tool not found in given path by **[szhajdu](https://github.com/szhajdu)** in https://github.com/Codeception/module-db/pull/80
23+
* test: Run test against PHP 8.4 by **[W0rma](https://github.com/W0rma)** in https://github.com/Codeception/module-db/pull/77
24+
* test: Avoid deprecated direct access to driver and dbh property by **[W0rma](https://github.com/W0rma)** in https://github.com/Codeception/module-db/pull/81
25+
* docs: Fix yaml format in PHPDoc and remove duplication by **[ThomasLandauer](https://github.com/ThomasLandauer)** in https://github.com/Codeception/module-db/pull/78
26+
* chore: Remove unnecessary files from Composer package by **[s1lver](https://github.com/s1lver)** in https://github.com/Codeception/module-db/pull/83
27+
28+
## New Contributors
29+
* **[ThomasLandauer](https://github.com/ThomasLandauer)** made their first contribution in https://github.com/Codeception/module-db/pull/78
30+
* **[s1lver](https://github.com/s1lver)** made their first contribution in https://github.com/Codeception/module-db/pull/83
31+
32+
**Full Changelog**: https://github.com/Codeception/module-db/compare/3.1.4...3.2.0
33+
34+
1235
### module-laravel 3.2.0: 3.2.0
1336

1437
Released by [![](https://avatars.githubusercontent.com/u/64917965?v=4&s=16) TavoNiievez](https://github.com/TavoNiievez) on 2025/01/13 11:42:45 / [Repository](https://github.com/Codeception/module-laravel) / [Releases](https://github.com/Codeception/module-laravel/releases)

docs/modules/Db.md

Lines changed: 93 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The most important function of this module is to clean a database before each te
2525
This module also provides actions to perform checks in a database, e.g. [seeInDatabase()](https://codeception.com/docs/modules/Db#seeInDatabase)
2626

2727
In order to have your database populated with data you need a raw SQL dump.
28-
Simply put the dump in the `tests/_data` directory (by default) and specify the path in the config.
28+
Simply put the dump in the `tests/Support/Data` directory (by default) and specify the path in the config.
2929
The next time after the database is cleared, all your data will be restored from the dump.
3030
Don't forget to include `CREATE TABLE` statements in the dump.
3131

@@ -40,85 +40,80 @@ Also available:
4040
* MS SQL
4141
* Oracle
4242

43-
Connection is done by database Drivers, which are stored in the `Codeception\Lib\Driver` namespace.
44-
[Check out the drivers](https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Lib/Driver)
45-
if you run into problems loading dumps and cleaning databases.
46-
47-
### Config
48-
49-
* dsn *required* - PDO DSN
50-
* user *required* - username to access database
51-
* password *required* - password
52-
* dump - path to database dump
53-
* populate: false - whether the the dump should be loaded before the test suite is started
54-
* cleanup: false - whether the dump should be reloaded before each test
55-
* reconnect: false - whether the module should reconnect to the database before each test
56-
* waitlock: 0 - wait lock (in seconds) that the database session should use for DDL statements
57-
* ssl_key - path to the SSL key (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key)
58-
* 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)
59-
* 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)
60-
* ssl_verify_server_cert - disables certificate CN verification (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php)
61-
* 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)
62-
* databases - include more database configs and switch between them in tests.
63-
* 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
64-
* 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
65-
### Example
66-
67-
modules:
68-
enabled:
69-
- Db:
70-
dsn: 'mysql:host=localhost;dbname=testdb'
71-
user: 'root'
72-
password: ''
73-
dump: 'tests/_data/dump.sql'
74-
populate: true
75-
cleanup: true
76-
reconnect: true
77-
waitlock: 10
78-
skip_cleanup_if_failed: true
79-
ssl_key: '/path/to/client-key.pem'
80-
ssl_cert: '/path/to/client-cert.pem'
81-
ssl_ca: '/path/to/ca-cert.pem'
82-
ssl_verify_server_cert: false
83-
ssl_cipher: 'AES256-SHA'
84-
initial_queries:
85-
- 'CREATE DATABASE IF NOT EXISTS temp_db;'
86-
- 'USE temp_db;'
87-
- 'SET NAMES utf8;'
43+
Connection is done by database drivers, which are stored in the `Codeception\Lib\Driver` namespace.
44+
Check out the drivers if you run into problems loading dumps and cleaning databases.
45+
46+
### Example `Functional.suite.yml`
47+
{% highlight yaml %}
48+
49+
modules:
50+
enabled:
51+
- Db:
52+
dsn: 'mysql:host=localhost;dbname=testdb'
53+
user: 'root'
54+
password: ''
55+
dump: 'tests/Support/Data/dump.sql'
56+
populate: true # whether the dump should be loaded before the test suite is started
57+
cleanup: true # whether the dump should be reloaded before each test
58+
reconnect: true # whether the module should reconnect to the database before each test
59+
waitlock: 10 # wait lock (in seconds) that the database session should use for DDL statements
60+
databases: # include more database configs and switch between them in tests.
61+
skip_cleanup_if_failed: true # Do not perform the cleanup if the tests failed. If this is used, manual cleanup might be required when re-running
62+
ssl_key: '/path/to/client-key.pem' # path to the SSL key (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key)
63+
ssl_cert: '/path/to/client-cert.pem' # path to the SSL certificate (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert)
64+
ssl_ca: '/path/to/ca-cert.pem' # path to the SSL certificate authority (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca)
65+
ssl_verify_server_cert: false # disables certificate CN verification (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php)
66+
ssl_cipher: 'AES256-SHA' # 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)
67+
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
68+
- 'CREATE DATABASE IF NOT EXISTS temp_db;'
69+
- 'USE temp_db;'
70+
- 'SET NAMES utf8;'
71+
72+
{% endhighlight %}
8873

8974
### Example with multi-dumps
90-
modules:
91-
enabled:
92-
- Db:
93-
dsn: 'mysql:host=localhost;dbname=testdb'
94-
user: 'root'
95-
password: ''
96-
dump:
97-
- 'tests/_data/dump.sql'
98-
- 'tests/_data/dump-2.sql'
75+
{% highlight yaml %}
76+
77+
modules:
78+
enabled:
79+
- Db:
80+
dsn: 'mysql:host=localhost;dbname=testdb'
81+
user: 'root'
82+
password: ''
83+
dump:
84+
- 'tests/Support/Data/dump.sql'
85+
- 'tests/Support/Data/dump-2.sql'
86+
87+
{% endhighlight %}
9988

10089
### Example with multi-databases
90+
{% highlight yaml %}
10191

102-
modules:
103-
enabled:
104-
- Db:
105-
dsn: 'mysql:host=localhost;dbname=testdb'
106-
user: 'root'
107-
password: ''
108-
databases:
92+
modules:
93+
enabled:
94+
- Db:
95+
dsn: 'mysql:host=localhost;dbname=testdb'
96+
user: 'root'
97+
password: ''
98+
databases:
10999
db2:
110-
dsn: 'mysql:host=localhost;dbname=testdb2'
111-
user: 'userdb2'
112-
password: ''
100+
dsn: 'mysql:host=localhost;dbname=testdb2'
101+
user: 'userdb2'
102+
password: ''
103+
104+
{% endhighlight %}
113105

114-
### Example with Sqlite
106+
### Example with SQLite
107+
{% highlight yaml %}
108+
109+
modules:
110+
enabled:
111+
- Db:
112+
dsn: 'sqlite:relative/path/to/sqlite-database.db'
113+
user: ''
114+
password: ''
115115

116-
modules:
117-
enabled:
118-
- Db:
119-
dsn: 'sqlite:relative/path/to/sqlite-database.db'
120-
user: ''
121-
password: ''
116+
{% endhighlight %}
122117

123118
### SQL data dump
124119

@@ -134,31 +129,32 @@ For MySQL:
134129
{% highlight yaml %}
135130

136131
modules:
137-
enabled:
138-
- Db:
139-
dsn: 'mysql:host=localhost;dbname=testdb'
140-
user: 'root'
141-
password: ''
142-
dump: 'tests/_data/dump.sql'
143-
populate: true # run populator before all tests
144-
cleanup: true # run populator before each test
145-
populator: 'mysql -u $user -h $host $dbname < $dump'
132+
enabled:
133+
- Db:
134+
dsn: 'mysql:host=localhost;dbname=testdb'
135+
user: 'root'
136+
password: ''
137+
dump: 'tests/Support/Data/dump.sql'
138+
populate: true # run populator before all tests
139+
cleanup: true # run populator before each test
140+
populator: 'mysql -u $user -h $host $dbname < $dump'
146141

147142
{% endhighlight %}
148143

149-
For PostgreSQL (using pg_restore)
144+
For PostgreSQL (using `pg_restore`)
150145

151146
{% highlight yaml %}
147+
152148
modules:
153-
enabled:
154-
- Db:
155-
dsn: 'pgsql:host=localhost;dbname=testdb'
156-
user: 'root'
157-
password: ''
158-
dump: 'tests/_data/db_backup.dump'
159-
populate: true # run populator before all tests
160-
cleanup: true # run populator before each test
161-
populator: 'pg_restore -u $user -h $host -D $dbname < $dump'
149+
enabled:
150+
- Db:
151+
dsn: 'pgsql:host=localhost;dbname=testdb'
152+
user: 'root'
153+
password: ''
154+
dump: 'tests/Support/Data/db_backup.dump'
155+
populate: true # run populator before all tests
156+
cleanup: true # run populator before each test
157+
populator: 'pg_restore -u $user -h $host -D $dbname < $dump'
162158

163159
{% endhighlight %}
164160

@@ -334,7 +330,7 @@ Provide table name, desired column and criteria.
334330
{% highlight php %}
335331

336332
<?php
337-
$mails = $I->grabColumnFromDatabase('users', 'email', array('name' => 'RebOOter'));
333+
$mails = $I->grabColumnFromDatabase('users', 'email', ['name' => 'RebOOter']);
338334

339335
{% endhighlight %}
340336

@@ -353,7 +349,7 @@ Provide table name and criteria.
353349
{% highlight php %}
354350

355351
<?php
356-
$mail = $I->grabEntriesFromDatabase('users', array('name' => 'Davert'));
352+
$mail = $I->grabEntriesFromDatabase('users', ['name' => 'Davert']);
357353

358354
{% endhighlight %}
359355
Comparison expressions can be used as well:
@@ -384,7 +380,7 @@ Provide table name, desired column and criteria.
384380
{% highlight php %}
385381

386382
<?php
387-
$mail = $I->grabEntryFromDatabase('users', array('name' => 'Davert'));
383+
$mail = $I->grabEntryFromDatabase('users', ['name' => 'Davert']);
388384

389385
{% endhighlight %}
390386
Comparison expressions can be used as well:
@@ -414,7 +410,7 @@ Provide table name, desired column and criteria.
414410
{% highlight php %}
415411

416412
<?php
417-
$mail = $I->grabFromDatabase('users', 'email', array('name' => 'Davert'));
413+
$mail = $I->grabFromDatabase('users', 'email', ['name' => 'Davert']);
418414

419415
{% endhighlight %}
420416
Comparison expressions can be used as well:
@@ -451,7 +447,7 @@ unless you've configured "skip_cleanup_if_failed", and the test fails.
451447
{% highlight php %}
452448

453449
<?php
454-
$I->haveInDatabase('users', array('name' => 'miles', 'email' => '[email protected]'));
450+
$I->haveInDatabase('users', ['name' => 'miles', 'email' => '[email protected]']);
455451

456452
{% endhighlight %}
457453

@@ -559,7 +555,7 @@ Update an SQL record into a database.
559555
{% highlight php %}
560556

561557
<?php
562-
$I->updateInDatabase('users', array('isAdmin' => true), array('email' => '[email protected]'));
558+
$I->updateInDatabase('users', ['isAdmin' => true], ['email' => '[email protected]']);
563559

564560
{% endhighlight %}
565561

0 commit comments

Comments
 (0)