generated from vjik/package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix column and table names quoting (#5)
- Loading branch information
Showing
27 changed files
with
2,225 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
on: | ||
pull_request: | ||
push: | ||
branches: [ 'master' ] | ||
|
||
name: PgSQL build | ||
|
||
jobs: | ||
tests: | ||
name: PHP ${{ matrix.php }}-${{ matrix.os }} | ||
|
||
env: | ||
key: cache-v1 | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
|
||
php: | ||
- "8.0" | ||
- "8.1" | ||
- "8.2" | ||
- "8.3" | ||
|
||
pgsql: | ||
- 16 | ||
|
||
services: | ||
postgres: | ||
image: postgres:${{ matrix.pgsql }} | ||
env: | ||
POSTGRES_USER: root | ||
POSTGRES_PASSWORD: root | ||
POSTGRES_DB: db_test | ||
ports: | ||
- 5432:5432 | ||
options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
ini-values: date.timezone='UTC' | ||
coverage: pcov | ||
tools: composer:v2 | ||
|
||
- name: Install Composer dependencies | ||
uses: ramsey/composer-install@v3 | ||
|
||
- name: Run unit tests | ||
run: vendor/bin/codecept run Unit | ||
|
||
- name: Run integration tests | ||
run: vendor/bin/codecept run PgSqlIntegration | ||
|
||
- name: Run preload tests | ||
run: vendor/bin/codecept run PgSqlPreload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
tests/Integration.suite.yml → tests/MySqlIntegration.suite.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\Integration | ||
actor: IntegrationTester | ||
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\MySqlIntegration | ||
actor: MySqlIntegrationTester | ||
modules: | ||
enabled: | ||
- Db: | ||
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%' | ||
user: '%DB_USERNAME%' | ||
password: '%DB_PASSWORD%' | ||
- Vjik\Codeception\DatabasePopulator\Module: | ||
dumpsPath: 'tests/_data/dumps' | ||
dumpsPath: 'tests/_data/dumps/mysql' | ||
rowsPath: 'tests/_data/rows' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\Preload | ||
actor: PreloadTester | ||
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\MySqlPreload | ||
actor: MySqlPreloadTester | ||
modules: | ||
enabled: | ||
- Db: | ||
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%' | ||
user: '%DB_USERNAME%' | ||
password: '%DB_PASSWORD%' | ||
- Vjik\Codeception\DatabasePopulator\Module: | ||
dumpsPath: 'tests/_data/dumps' | ||
dumpsPath: 'tests/_data/dumps/mysql' | ||
rowsPath: 'tests/_data/rows' | ||
preloadDump: 'blog' | ||
preloadRows: 'authors' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\PgSqlIntegration | ||
actor: PgSqlIntegrationTester | ||
modules: | ||
enabled: | ||
- Db: | ||
dsn: 'pgsql:host=%DB_HOST%;dbname=%DB_NAME%' | ||
user: '%DB_USERNAME%' | ||
password: '%DB_PASSWORD%' | ||
- Vjik\Codeception\DatabasePopulator\Module: | ||
dumpsPath: 'tests/_data/dumps/pgsql' | ||
rowsPath: 'tests/_data/rows' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\Codeception\DatabasePopulator\Tests\PgSqlIntegration; | ||
|
||
use Codeception\Exception\ModuleException; | ||
use Codeception\Test\Unit; | ||
use PDO; | ||
use Vjik\Codeception\DatabasePopulator\Tests\PgSqlIntegrationTester; | ||
|
||
use function dirname; | ||
|
||
final class DatabasePopulateTest extends Unit | ||
{ | ||
/** | ||
* @var PgSqlIntegrationTester | ||
*/ | ||
protected $tester; | ||
|
||
public function testBase(): void | ||
{ | ||
$this->tester->loadDump('blog'); | ||
$this->tester->loadRows('authors'); | ||
|
||
$this->tester->seeInDatabase('author', ['id' => 1, 'name' => 'Ivan']); | ||
$this->tester->seeInDatabase('author', ['id' => 2, 'name' => 'Petr']); | ||
} | ||
|
||
public function testLoadNotExistDump(): void | ||
{ | ||
$this->expectException(ModuleException::class); | ||
$this->expectExceptionMessage( | ||
"\nFile with dump doesn't exist.\nPlease, check path for SQL-file: " . | ||
dirname(__DIR__) . '/_data/dumps/pgsql/shop.sql' | ||
); | ||
$this->tester->loadDump('shop'); | ||
} | ||
|
||
public function testLoadEmptyDump(): void | ||
{ | ||
$this->tester->loadDump('blog'); | ||
$this->tester->loadDump('empty'); | ||
|
||
/** @var PDO $pdo */ | ||
$pdo = $this->getModule('Db')->_getDbh(); | ||
$tableNames = $pdo->query('SELECT table_name FROM information_schema.tables WHERE table_schema=\'public\' AND table_type=\'BASE TABLE\'')->fetchAll(PDO::FETCH_COLUMN); | ||
|
||
$this->assertSame([], $tableNames); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
suite_namespace: Vjik\Codeception\DatabasePopulator\Tests\PgSqlPreload | ||
actor: PgSqlPreloadTester | ||
modules: | ||
enabled: | ||
- Db: | ||
dsn: 'pgsql:host=%DB_HOST%;dbname=%DB_NAME%' | ||
user: '%DB_USERNAME%' | ||
password: '%DB_PASSWORD%' | ||
- Vjik\Codeception\DatabasePopulator\Module: | ||
dumpsPath: 'tests/_data/dumps/pgsql' | ||
rowsPath: 'tests/_data/rows' | ||
preloadDump: 'blog' | ||
preloadRows: 'authors' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\Codeception\DatabasePopulator\Tests\PgSqlPreload; | ||
|
||
use Codeception\Test\Unit; | ||
use Vjik\Codeception\DatabasePopulator\Tests\PgSqlPreloadTester; | ||
|
||
final class PreloadTest extends Unit | ||
{ | ||
/** | ||
* @var PgSqlPreloadTester | ||
*/ | ||
protected $tester; | ||
|
||
public function testBase(): void | ||
{ | ||
$this->tester->seeInDatabase('author', ['id' => 1, 'name' => 'Ivan']); | ||
$this->tester->seeInDatabase('author', ['id' => 2, 'name' => 'Petr']); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.