Skip to content

Commit 517da09

Browse files
committed
fix
1 parent f125ef2 commit 517da09

8 files changed

+944
-5
lines changed

tests/PgSqlIntegration.suite.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\Integration
2-
actor: IntegrationTester
1+
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\PgSqlIntegration
2+
actor: PgSqlIntegrationTester
33
modules:
44
enabled:
55
- Db:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Vjik\Codeception\DatabasePopulator\Tests\PgSqlIntegration;
6+
7+
use Codeception\Exception\ModuleException;
8+
use Codeception\Test\Unit;
9+
use PDO;
10+
use Vjik\Codeception\DatabasePopulator\Tests\PgSqlIntegrationTester;
11+
12+
use function dirname;
13+
14+
final class DatabasePopulateTest extends Unit
15+
{
16+
/**
17+
* @var PgSqlIntegrationTester
18+
*/
19+
protected $tester;
20+
21+
public function testBase(): void
22+
{
23+
$this->tester->loadDump('blog');
24+
$this->tester->loadRows('authors');
25+
26+
$this->tester->seeInDatabase('author', ['id' => 1, 'name' => 'Ivan']);
27+
$this->tester->seeInDatabase('author', ['id' => 2, 'name' => 'Petr']);
28+
}
29+
30+
public function testLoadNotExistDump(): void
31+
{
32+
$this->expectException(ModuleException::class);
33+
$this->expectExceptionMessage(
34+
"\nFile with dump doesn't exist.\nPlease, check path for SQL-file: " .
35+
dirname(__DIR__) . '/_data/dumps/pgsql/shop.sql'
36+
);
37+
$this->tester->loadDump('shop');
38+
}
39+
40+
public function testLoadEmptyDump(): void
41+
{
42+
$this->tester->loadDump('blog');
43+
$this->tester->loadDump('empty');
44+
45+
/** @var PDO $pdo */
46+
$pdo = $this->getModule('Db')->_getDbh();
47+
$tableNames = $pdo->query('SHOW TABLES')->fetchAll(PDO::FETCH_COLUMN);
48+
49+
$this->assertSame([], $tableNames);
50+
}
51+
}

tests/PgSqlPreload.suite.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\Preload
2-
actor: PreloadTester
1+
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\PgSqlPreload
2+
actor: PgSqlPreloadTester
33
modules:
44
enabled:
55
- Db:
6-
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%'
6+
dsn: 'pgsql:host=%DB_HOST%;dbname=%DB_NAME%'
77
user: '%DB_USERNAME%'
88
password: '%DB_PASSWORD%'
99
- Vjik\Codeception\DatabasePopulator\Module:

tests/PgSqlPreload/PreloadTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Vjik\Codeception\DatabasePopulator\Tests\PgSqlPreload;
6+
7+
use Codeception\Test\Unit;
8+
use Vjik\Codeception\DatabasePopulator\Tests\PgSqlPreloadTester;
9+
10+
final class PreloadTest extends Unit
11+
{
12+
/**
13+
* @var PgSqlPreloadTester
14+
*/
15+
protected $tester;
16+
17+
public function testBase(): void
18+
{
19+
$this->tester->seeInDatabase('author', ['id' => 1, 'name' => 'Ivan']);
20+
$this->tester->seeInDatabase('author', ['id' => 2, 'name' => 'Petr']);
21+
}
22+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Vjik\Codeception\DatabasePopulator\Tests;
6+
7+
/**
8+
* Inherited Methods
9+
* @method void wantTo($text)
10+
* @method void wantToTest($text)
11+
* @method void execute($callable)
12+
* @method void expectTo($prediction)
13+
* @method void expect($prediction)
14+
* @method void amGoingTo($argumentation)
15+
* @method void am($role)
16+
* @method void lookForwardTo($achieveValue)
17+
* @method void comment($description)
18+
* @method void pause($vars = [])
19+
*
20+
* @SuppressWarnings(PHPMD)
21+
*/
22+
class PgSqlIntegrationTester extends \Codeception\Actor
23+
{
24+
use _generated\PgSqlIntegrationTesterActions;
25+
26+
/**
27+
* Define custom actions here
28+
*/
29+
}

tests/_support/PgSqlPreloadTester.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Vjik\Codeception\DatabasePopulator\Tests;
6+
7+
/**
8+
* Inherited Methods
9+
* @method void wantTo($text)
10+
* @method void wantToTest($text)
11+
* @method void execute($callable)
12+
* @method void expectTo($prediction)
13+
* @method void expect($prediction)
14+
* @method void amGoingTo($argumentation)
15+
* @method void am($role)
16+
* @method void lookForwardTo($achieveValue)
17+
* @method void comment($description)
18+
* @method void pause($vars = [])
19+
*
20+
* @SuppressWarnings(PHPMD)
21+
*/
22+
class PgSqlPreloadTester extends \Codeception\Actor
23+
{
24+
use _generated\PgSqlPreloadTesterActions;
25+
26+
/**
27+
* Define custom actions here
28+
*/
29+
}

0 commit comments

Comments
 (0)