Merge pull request #7181 from yguedidi/remove-need-for-test_database_path

Remove need for TEST_DATABASE_PATH
This commit is contained in:
Yassine Guedidi 2024-01-16 11:08:26 +01:00 committed by GitHub
commit 325ff1a419
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 12 deletions

View file

@ -1,5 +1,2 @@
parameters:
# Using an environment variable in order to avoid the error "attempt to write a readonly database"
# when the schema is dropped then recreate
database_path: "%env(TEST_DATABASE_PATH)%"
env(TEST_DATABASE_PATH): "%kernel.project_dir%/data/db/wallabag_test.sqlite"
database_path: "%kernel.project_dir%/data/db/wallabag_test.sqlite"

View file

@ -1,5 +1,2 @@
parameters:
env(DATABASE_URL): sqlite://:@localhost/%env(TEST_DATABASE_PATH)%?charset=utf8
# Using an environment variable in order to avoid the error "attempt to write a readonly database"
# when the schema is dropped then recreate
env(TEST_DATABASE_PATH): "%kernel.project_dir%/data/db/wallabag_test.sqlite"
env(DATABASE_URL): sqlite:///%kernel.project_dir%/data/db/wallabag_test.sqlite?charset=utf8

View file

@ -56,7 +56,7 @@ class InstallCommandTest extends WallabagCoreTestCase
// check the manual that corresponds to your MariaDB server version for the right syntax to use
// near '/tmp/wallabag_testTYj1kp' at line 1
$databasePath = tempnam(sys_get_temp_dir(), 'wallabag_test');
putenv("TEST_DATABASE_PATH=$databasePath");
putenv("DATABASE_URL=sqlite:///$databasePath?charset=utf8");
// The environnement has been changed, recreate the client in order to update connection
parent::setUp();
@ -67,9 +67,10 @@ class InstallCommandTest extends WallabagCoreTestCase
protected function tearDown(): void
{
$databasePath = getenv('TEST_DATABASE_PATH');
// Remove variable environnement
putenv('TEST_DATABASE_PATH');
$databaseUrl = getenv('DATABASE_URL');
$databasePath = parse_url($databaseUrl, \PHP_URL_PATH);
// Remove the real environnement variable
putenv('DATABASE_URL');
if ($databasePath && file_exists($databasePath)) {
unlink($databasePath);