Remove need for TEST_DATABASE_PATH

This commit is contained in:
Yassine Guedidi 2024-01-14 23:16:31 +01:00
parent ab3eaf2d3d
commit 7e40142aa0
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);