Skip to content

Commit c56b860

Browse files
committed
fix: Configure SQLite database for testing environment
- Add SQLite in-memory database configuration to phpunit.xml.dist - Configure database connection in TestCase::getEnvironmentSetUp() - Ensures ApiHealthCheck tests pass with prefer-lowest dependencies - Fixes CI failures on GitHub Actions with Laravel 10.0.0 This fix ensures that health check tests have a proper database connection even in minimal dependency environments (prefer-lowest). The issue was only visible in CI with older Laravel versions.
1 parent fb48f98 commit c56b860

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@
2121
<php>
2222
<env name="APP_ENV" value="testing"/>
2323
<env name="APP_KEY" value="base64:2fl3UtcWC66FVXoS8qvwvEogzwk5qPqxZ1h5rJNqx8I="/>
24+
<env name="DB_CONNECTION" value="sqlite"/>
25+
<env name="DB_DATABASE" value=":memory:"/>
26+
<env name="CACHE_DRIVER" value="array"/>
27+
<env name="QUEUE_CONNECTION" value="sync"/>
2428
</php>
2529
</phpunit>

tests/TestCase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,19 @@ protected function getEnvironmentSetUp($app)
5151
{
5252
config(['laravel-page-speed.enable' => true]);
5353
config(['laravel-page-speed.skip' => []]);
54+
55+
// Configure database for testing (especially for prefer-lowest scenarios)
56+
$app['config']->set('database.default', 'testing');
57+
$app['config']->set('database.connections.testing', [
58+
'driver' => 'sqlite',
59+
'database' => ':memory:',
60+
'prefix' => '',
61+
]);
62+
63+
// Configure cache for testing
64+
$app['config']->set('cache.default', 'array');
65+
66+
// Configure queue for testing
67+
$app['config']->set('queue.default', 'sync');
5468
}
5569
}

0 commit comments

Comments
 (0)