mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-22 17:11:07 +00:00
Make tests use dev database config
This commit is contained in:
parent
aa7dd67131
commit
8d3f575c03
6 changed files with 16 additions and 59 deletions
|
@ -100,22 +100,12 @@ class AppKernel extends Kernel
|
|||
|
||||
$loader->load(function (ContainerBuilder $container) {
|
||||
$this->processDatabaseParameters($container);
|
||||
|
||||
if ('test' === $container->getParameter('kernel.environment')) {
|
||||
$this->processDatabaseParameters($container, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function processDatabaseParameters(ContainerBuilder $container, bool $isTest = false)
|
||||
private function processDatabaseParameters(ContainerBuilder $container)
|
||||
{
|
||||
$prefix = '';
|
||||
|
||||
if ($isTest) {
|
||||
$prefix = 'test_';
|
||||
}
|
||||
|
||||
switch ($container->getParameter($prefix . 'database_driver')) {
|
||||
switch ($container->getParameter('database_driver')) {
|
||||
case 'pdo_mysql':
|
||||
$scheme = 'mysql';
|
||||
break;
|
||||
|
@ -126,18 +116,18 @@ class AppKernel extends Kernel
|
|||
$scheme = 'sqlite';
|
||||
break;
|
||||
default:
|
||||
throw new \RuntimeException('Unsupported database driver: ' . $container->getParameter($prefix . 'database_driver'));
|
||||
throw new \RuntimeException('Unsupported database driver: ' . $container->getParameter('database_driver'));
|
||||
}
|
||||
|
||||
$container->setParameter($prefix . 'database_scheme', $scheme);
|
||||
$container->setParameter('database_scheme', $scheme);
|
||||
|
||||
if ('sqlite' === $scheme) {
|
||||
$container->setParameter($prefix . 'database_name', $container->getParameter($prefix . 'database_path'));
|
||||
$container->setParameter('database_name', $container->getParameter('database_path'));
|
||||
}
|
||||
|
||||
$container->setParameter($prefix . 'database_user', (string) $container->getParameter($prefix . 'database_user'));
|
||||
$container->setParameter($prefix . 'database_password', (string) $container->getParameter($prefix . 'database_password'));
|
||||
$container->setParameter($prefix . 'database_port', (string) $container->getParameter($prefix . 'database_port'));
|
||||
$container->setParameter($prefix . 'database_socket', (string) $container->getParameter($prefix . 'database_socket'));
|
||||
$container->setParameter('database_user', (string) $container->getParameter('database_user'));
|
||||
$container->setParameter('database_password', (string) $container->getParameter('database_password'));
|
||||
$container->setParameter('database_port', (string) $container->getParameter('database_port'));
|
||||
$container->setParameter('database_socket', (string) $container->getParameter('database_socket'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ imports:
|
|||
- { resource: services_test.yml }
|
||||
|
||||
parameters:
|
||||
env(TEST_DATABASE_URL): '%test_database_scheme%://%test_database_user%:%test_database_password%@%test_database_host%:%test_database_port%/%test_database_name%?unix_socket=%test_database_socket%&charset=%test_database_charset%'
|
||||
fosuser_registration: true
|
||||
|
||||
framework:
|
||||
|
@ -24,7 +23,7 @@ web_profiler:
|
|||
|
||||
doctrine:
|
||||
dbal:
|
||||
url: '%env(resolve:TEST_DATABASE_URL)%'
|
||||
dbname_suffix: '_test' # for MySQL and PostgreSQL
|
||||
|
||||
orm:
|
||||
metadata_cache_driver:
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
parameters:
|
||||
test_database_driver: pdo_sqlite
|
||||
test_database_host: 127.0.0.1
|
||||
test_database_port: null
|
||||
test_database_name: null
|
||||
test_database_user: null
|
||||
test_database_password: null
|
||||
test_database_path: "%env(TEST_DATABASE_PATH)%"
|
||||
# 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"
|
||||
test_database_socket: null
|
||||
test_database_charset: utf8
|
||||
|
|
|
@ -1,11 +1,2 @@
|
|||
parameters:
|
||||
test_database_driver: pdo_mysql
|
||||
test_database_host: 127.0.0.1
|
||||
test_database_port: 3306
|
||||
test_database_name: wallabag_test
|
||||
test_database_user: root
|
||||
test_database_password: root
|
||||
test_database_path: ~
|
||||
env(TEST_DATABASE_PATH): ~
|
||||
test_database_socket: null
|
||||
test_database_charset: utf8mb4
|
||||
env(DATABASE_URL): mysql://root:root@127.0.0.1:3306/wallabag?charset=utf8mb4
|
||||
|
|
|
@ -1,11 +1,2 @@
|
|||
parameters:
|
||||
test_database_driver: pdo_pgsql
|
||||
test_database_host: localhost
|
||||
test_database_port:
|
||||
test_database_name: wallabag_test
|
||||
test_database_user: wallabag
|
||||
test_database_password: wallabagrocks
|
||||
test_database_path: ~
|
||||
env(TEST_DATABASE_PATH): ~
|
||||
test_database_socket: null
|
||||
test_database_charset: utf8
|
||||
env(DATABASE_URL): postgres://wallabag:wallabagrocks@localhost/wallabag?charset=utf8
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
parameters:
|
||||
test_database_driver: pdo_sqlite
|
||||
test_database_host: localhost
|
||||
test_database_port:
|
||||
test_database_name: ~
|
||||
test_database_user: ~
|
||||
test_database_password: ~
|
||||
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
|
||||
test_database_path: "%env(TEST_DATABASE_PATH)%"
|
||||
env(TEST_DATABASE_PATH): "%kernel.project_dir%/data/db/wallabag_test.sqlite"
|
||||
test_database_socket: null
|
||||
test_database_charset: utf8
|
||||
|
|
Loading…
Reference in a new issue