Skip to content

Commit cb913c0

Browse files
authored
Add support for codeception/module-db:^2.0 and update dev dependencies (#2)
1 parent b4e680a commit cb913c0

File tree

7 files changed

+62
-133
lines changed

7 files changed

+62
-133
lines changed

.github/workflows/dependency.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: composer self-update
4444

4545
- name: Install maglnet/composer-require-checker
46-
run: composer require maglnet/composer-require-checker
46+
run: composer require maglnet/composer-require-checker:^3.8
4747

4848
- name: Check dependency
4949
run: vendor/bin/composer-require-checker check --config-file=dependency-checker.json

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Database Populator for Codeception DB Module Change Log
22

3-
## 1.0.0 under development
3+
## 1.0.1 December 27, 2021
4+
5+
- Enh #93: Add support for `codeception/module-db` version `^2.0`.
6+
7+
## 1.0.0 September 18, 2021
48

59
- Initial release.

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"php": "^7.4|^8.0",
1919
"ext-pdo": "*",
2020
"codeception/codeception": "^4.1",
21-
"codeception/module-db": "^1.1"
21+
"codeception/module-db": "^1.1|^2.0"
2222
},
2323
"require-dev": {
24-
"vimeo/psalm": "^4.10",
25-
"vlucas/phpdotenv": "^5.3"
24+
"vimeo/psalm": "^4.16",
25+
"vlucas/phpdotenv": "^5.4"
2626
},
2727
"autoload": {
2828
"psr-4": {

src/DatabasePopulator.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ final class DatabasePopulator
2222
public function __construct(Db $db, Config $config)
2323
{
2424
$this->dbDriver = $db->_getDriver();
25-
/** @var PDO */
2625
$this->dbh = $db->_getDbh();
2726
$this->config = $config;
2827
}
@@ -118,6 +117,8 @@ private function afterLoadRows(): void
118117
/**
119118
* @see Db::readSqlFile
120119
* @see Db::readSql
120+
*
121+
* @return string[]
121122
*/
122123
private function readDump(string $dump): array
123124
{

tests/_support/_generated/IntegrationTesterActions.php

+25-63
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php //[STAMP] f42e5bb6e7d59c610037cae7f412a84d
1+
<?php //[STAMP] b0f4e34cc85e2868044e220d003d5a70
22
namespace Vjik\Codeception\DatabasePopulator\Tests\_generated;
33

44
// This class was automatically generated by build task
@@ -25,12 +25,12 @@ abstract protected function getScenario();
2525
* $I->seeNumRecords(30, 'books'); //executed on db_books database
2626
* //All the next queries will be on db_books
2727
* ```
28-
* @param $databaseKey
28+
*
2929
* @throws ModuleConfigException
3030
* @see \Codeception\Module\Db::amConnectedToDatabase()
3131
*/
32-
public function amConnectedToDatabase($databaseKey) {
33-
return $this->getScenario()->runStep(new \Codeception\Step\Condition('amConnectedToDatabase', func_get_args()));
32+
public function amConnectedToDatabase(string $databaseKey): void {
33+
$this->getScenario()->runStep(new \Codeception\Step\Condition('amConnectedToDatabase', func_get_args()));
3434
}
3535

3636

@@ -67,12 +67,12 @@ public function amConnectedToDatabase($databaseKey) {
6767
* exception on failure.
6868
*
6969
* @param $databaseKey
70-
* @param \Codeception\Util\ActionSequence|array|callable $actions
70+
* @param ActionSequence|array|callable $actions
7171
* @throws ModuleConfigException
7272
* @see \Codeception\Module\Db::performInDatabase()
7373
*/
74-
public function performInDatabase($databaseKey, $actions) {
75-
return $this->getScenario()->runStep(new \Codeception\Step\Action('performInDatabase', func_get_args()));
74+
public function performInDatabase($databaseKey, $actions): void {
75+
$this->getScenario()->runStep(new \Codeception\Step\Action('performInDatabase', func_get_args()));
7676
}
7777

7878

@@ -84,16 +84,10 @@ public function performInDatabase($databaseKey, $actions) {
8484
* ```php
8585
* <?php
8686
* $I->haveInDatabase('users', array('name' => 'miles', 'email' => '[email protected]'));
87-
* ?>
8887
* ```
89-
*
90-
* @param string $table
91-
* @param array $data
92-
*
93-
* @return integer $id
9488
* @see \Codeception\Module\Db::haveInDatabase()
9589
*/
96-
public function haveInDatabase($table, array $data) {
90+
public function haveInDatabase(string $table, array $data): int {
9791
return $this->getScenario()->runStep(new \Codeception\Step\Action('haveInDatabase', func_get_args()));
9892
}
9993

@@ -119,14 +113,10 @@ public function haveInDatabase($table, array $data) {
119113
* ```
120114
*
121115
* Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
122-
*
123-
*
124-
* @param string $table
125-
* @param array $criteria
126116
* @see \Codeception\Module\Db::seeInDatabase()
127117
*/
128-
public function seeInDatabase($table, $criteria = []) {
129-
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInDatabase', func_get_args()));
118+
public function seeInDatabase(string $table, array $criteria = []): void {
119+
$this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInDatabase', func_get_args()));
130120
}
131121
/**
132122
* [!] Method is generated. Documentation taken from corresponding module.
@@ -150,14 +140,10 @@ public function seeInDatabase($table, $criteria = []) {
150140
* ```
151141
*
152142
* Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
153-
*
154-
*
155-
* @param string $table
156-
* @param array $criteria
157143
* @see \Codeception\Module\Db::seeInDatabase()
158144
*/
159-
public function canSeeInDatabase($table, $criteria = []) {
160-
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInDatabase', func_get_args()));
145+
public function canSeeInDatabase(string $table, array $criteria = []): void {
146+
$this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInDatabase', func_get_args()));
161147
}
162148

163149

@@ -169,16 +155,15 @@ public function canSeeInDatabase($table, $criteria = []) {
169155
* ```php
170156
* <?php
171157
* $I->seeNumRecords(1, 'users', ['name' => 'davert'])
172-
* ?>
173158
* ```
174159
*
175160
* @param int $expectedNumber Expected number
176161
* @param string $table Table name
177162
* @param array $criteria Search criteria [Optional]
178163
* @see \Codeception\Module\Db::seeNumRecords()
179164
*/
180-
public function seeNumRecords($expectedNumber, $table, array $criteria = []) {
181-
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumRecords', func_get_args()));
165+
public function seeNumRecords(int $expectedNumber, string $table, array $criteria = []): void {
166+
$this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumRecords', func_get_args()));
182167
}
183168
/**
184169
* [!] Method is generated. Documentation taken from corresponding module.
@@ -189,16 +174,15 @@ public function seeNumRecords($expectedNumber, $table, array $criteria = []) {
189174
* ```php
190175
* <?php
191176
* $I->seeNumRecords(1, 'users', ['name' => 'davert'])
192-
* ?>
193177
* ```
194178
*
195179
* @param int $expectedNumber Expected number
196180
* @param string $table Table name
197181
* @param array $criteria Search criteria [Optional]
198182
* @see \Codeception\Module\Db::seeNumRecords()
199183
*/
200-
public function canSeeNumRecords($expectedNumber, $table, array $criteria = []) {
201-
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumRecords', func_get_args()));
184+
public function canSeeNumRecords(int $expectedNumber, string $table, array $criteria = []): void {
185+
$this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumRecords', func_get_args()));
202186
}
203187

204188

@@ -225,13 +209,10 @@ public function canSeeNumRecords($expectedNumber, $table, array $criteria = [])
225209
* ```
226210
*
227211
* Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
228-
*
229-
* @param string $table
230-
* @param array $criteria
231212
* @see \Codeception\Module\Db::dontSeeInDatabase()
232213
*/
233-
public function dontSeeInDatabase($table, $criteria = []) {
234-
return $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInDatabase', func_get_args()));
214+
public function dontSeeInDatabase(string $table, array $criteria = []): void {
215+
$this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInDatabase', func_get_args()));
235216
}
236217
/**
237218
* [!] Method is generated. Documentation taken from corresponding module.
@@ -257,13 +238,10 @@ public function dontSeeInDatabase($table, $criteria = []) {
257238
* ```
258239
*
259240
* Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
260-
*
261-
* @param string $table
262-
* @param array $criteria
263241
* @see \Codeception\Module\Db::dontSeeInDatabase()
264242
*/
265-
public function cantSeeInDatabase($table, $criteria = []) {
266-
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInDatabase', func_get_args()));
243+
public function cantSeeInDatabase(string $table, array $criteria = []): void {
244+
$this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInDatabase', func_get_args()));
267245
}
268246

269247

@@ -277,15 +255,9 @@ public function cantSeeInDatabase($table, $criteria = []) {
277255
* <?php
278256
* $mails = $I->grabColumnFromDatabase('users', 'email', array('name' => 'RebOOter'));
279257
* ```
280-
*
281-
* @param string $table
282-
* @param string $column
283-
* @param array $criteria
284-
*
285-
* @return array
286258
* @see \Codeception\Module\Db::grabColumnFromDatabase()
287259
*/
288-
public function grabColumnFromDatabase($table, $column, array $criteria = []) {
260+
public function grabColumnFromDatabase(string $table, string $column, array $criteria = []): array {
289261
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabColumnFromDatabase', func_get_args()));
290262
}
291263

@@ -310,14 +282,10 @@ public function grabColumnFromDatabase($table, $column, array $criteria = []) {
310282
*
311283
* Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
312284
*
313-
* @param string $table
314-
* @param string $column
315-
* @param array $criteria
316-
*
317285
* @return mixed Returns a single column value or false
318286
* @see \Codeception\Module\Db::grabFromDatabase()
319287
*/
320-
public function grabFromDatabase($table, $column, $criteria = []) {
288+
public function grabFromDatabase(string $table, string $column, array $criteria = []) {
321289
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromDatabase', func_get_args()));
322290
}
323291

@@ -329,11 +297,10 @@ public function grabFromDatabase($table, $column, $criteria = []) {
329297
*
330298
* @param string $table Table name
331299
* @param array $criteria Search criteria [Optional]
332-
*
333300
* @return int
334301
* @see \Codeception\Module\Db::grabNumRecords()
335302
*/
336-
public function grabNumRecords($table, array $criteria = []) {
303+
public function grabNumRecords(string $table, array $criteria = []): int {
337304
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabNumRecords', func_get_args()));
338305
}
339306

@@ -346,16 +313,11 @@ public function grabNumRecords($table, array $criteria = []) {
346313
* ```php
347314
* <?php
348315
* $I->updateInDatabase('users', array('isAdmin' => true), array('email' => '[email protected]'));
349-
* ?>
350316
* ```
351-
*
352-
* @param string $table
353-
* @param array $data
354-
* @param array $criteria
355317
* @see \Codeception\Module\Db::updateInDatabase()
356318
*/
357-
public function updateInDatabase($table, array $data, array $criteria = []) {
358-
return $this->getScenario()->runStep(new \Codeception\Step\Action('updateInDatabase', func_get_args()));
319+
public function updateInDatabase(string $table, array $data, array $criteria = []): void {
320+
$this->getScenario()->runStep(new \Codeception\Step\Action('updateInDatabase', func_get_args()));
359321
}
360322

361323

0 commit comments

Comments
 (0)