Skip to content

Commit b9a3259

Browse files
authored
Set default connection settings for tests (#385)
1 parent 2e2491d commit b9a3259

4 files changed

Lines changed: 12 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ jobs:
9393

9494
- name: Run tests with phpunit with code coverage.
9595
run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always
96-
env:
97-
YII_PGSQL_DATABASE: yiitest
98-
YII_PGSQL_HOST: 127.0.0.1
99-
YII_PGSQL_PORT: 5432
100-
YII_PGSQL_USER: root
101-
YII_PGSQL_PASSWORD: root
10296

10397
- name: Upload coverage to Codecov.
10498
uses: codecov/codecov-action@v3

.github/workflows/mutation.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,3 @@ jobs:
7979
vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations --only-covered
8080
env:
8181
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
82-
YII_PGSQL_DATABASE: yiitest
83-
YII_PGSQL_HOST: 127.0.0.1
84-
YII_PGSQL_PORT: 5432
85-
YII_PGSQL_USER: root
86-
YII_PGSQL_PASSWORD: root

src/Schema.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use JsonException;
88
use Throwable;
99
use Yiisoft\Db\Constant\ColumnType;
10+
use Yiisoft\Db\Constant\ReferentialAction;
1011
use Yiisoft\Db\Constraint\CheckConstraint;
1112
use Yiisoft\Db\Constraint\Constraint;
1213
use Yiisoft\Db\Constraint\DefaultValueConstraint;
@@ -832,13 +833,13 @@ private function loadTableConstraints(string $tableName, string $returnType): ar
832833
ORDER BY "a"."attnum" ASC, "fa"."attnum" ASC
833834
SQL;
834835

835-
/** @psalm-var string[] $actionTypes */
836+
/** @psalm-var ReferentialAction::*[] $actionTypes */
836837
$actionTypes = [
837-
'a' => 'NO ACTION',
838-
'r' => 'RESTRICT',
839-
'c' => 'CASCADE',
840-
'n' => 'SET NULL',
841-
'd' => 'SET DEFAULT',
838+
'a' => ReferentialAction::NO_ACTION,
839+
'r' => ReferentialAction::RESTRICT,
840+
'c' => ReferentialAction::CASCADE,
841+
'n' => ReferentialAction::SET_NULL,
842+
'd' => ReferentialAction::SET_DEFAULT,
842843
];
843844

844845
$resolvedName = $this->resolveTableName($tableName);

tests/Support/TestTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ private function getDriver(): PdoDriverInterface
9393

9494
private static function getDatabaseName(): string
9595
{
96-
return getenv('YII_PGSQL_DATABASE') ?: '';
96+
return getenv('YII_PGSQL_DATABASE') ?: 'yiitest';
9797
}
9898

9999
private static function getHost(): string
100100
{
101-
return getenv('YII_PGSQL_HOST') ?: '';
101+
return getenv('YII_PGSQL_HOST') ?: '127.0.0.1';
102102
}
103103

104104
private static function getPort(): string
105105
{
106-
return getenv('YII_PGSQL_PORT') ?: '';
106+
return getenv('YII_PGSQL_PORT') ?: '5432';
107107
}
108108

109109
private static function getUsername(): string
110110
{
111-
return getenv('YII_PGSQL_USER') ?: '';
111+
return getenv('YII_PGSQL_USER') ?: 'root';
112112
}
113113

114114
private static function getPassword(): string
115115
{
116-
return getenv('YII_PGSQL_PASSWORD') ?: '';
116+
return getenv('YII_PGSQL_PASSWORD') ?: 'root';
117117
}
118118
}

0 commit comments

Comments
 (0)