Skip to content

Commit de0397a

Browse files
committed
Fix tests in CI
1 parent 639029d commit de0397a

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ jobs:
150150
- name: Execute all tests
151151
run: vendor/bin/paratest --testsuite Unit,Integration --stop-on-error && vendor/bin/phpunit --testsuite Browser --stop-on-error
152152
env:
153+
DB_HOST: 127.0.0.1
153154
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
155+
DB_PASSWORD: root
154156

155157
- uses: codecov/codecov-action@v6
156158
with:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"require-dev": {
4848
"area17/phptorch": "dev-main",
49-
"brianium/paratest": "^7.8",
49+
"brianium/paratest": "^6.0 | ^7.0",
5050
"chillerlan/php-qrcode": "~4.0",
5151
"friendsofphp/php-cs-fixer": "^3.0",
5252
"larastan/larastan": "^2.9 | ^3.0",

tests/integration/TestCase.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,24 +600,29 @@ protected static function prepareParallelTestbenchApplication(): void
600600

601601
protected static function configureParallelDatabase(): void
602602
{
603-
if (! self::parallelTestingToken() || ($_ENV['DB_CONNECTION'] ?? null) !== 'mysql') {
603+
if (! self::parallelTestingToken() || self::env('DB_CONNECTION') !== 'mysql') {
604604
return;
605605
}
606606

607-
$database = preg_replace('/_\d+$/', '', $_ENV['DB_DATABASE']) . '_' . self::parallelTestingToken();
607+
$database = preg_replace('/_\d+$/', '', self::env('DB_DATABASE')) . '_' . self::parallelTestingToken();
608608
$_ENV['DB_DATABASE'] = $_SERVER['DB_DATABASE'] = $database;
609609
putenv("DB_DATABASE={$database}");
610610

611-
$host = $_ENV['DB_HOST'] ?? '127.0.0.1';
612-
$port = $_ENV['DB_PORT'] ?? '3306';
613-
$username = $_ENV['DB_USERNAME'] ?? 'root';
614-
$password = $_ENV['DB_PASSWORD'] ?? '';
611+
$host = self::env('DB_HOST', '127.0.0.1');
612+
$port = self::env('DB_PORT', '3306');
613+
$username = self::env('DB_USERNAME', 'root');
614+
$password = self::env('DB_PASSWORD', '');
615615

616616
$pdo = new \PDO("mysql:host={$host};port={$port}", $username, $password);
617617
$pdo->exec("DROP DATABASE IF EXISTS `{$database}`");
618618
$pdo->exec("CREATE DATABASE `{$database}`");
619619
}
620620

621+
protected static function env(string $key, ?string $default = null): ?string
622+
{
623+
return getenv($key) ?: $_SERVER[$key] ?? $_ENV[$key] ?? $default;
624+
}
625+
621626
protected static function copyDirectory(string $source, string $target): void
622627
{
623628
mkdir($target, 0777, true);

0 commit comments

Comments
 (0)