mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 02:51:04 +00:00
Merge pull request #7161 from yguedidi/make-tests-use-dev-database-config
Make tests use dev database config
This commit is contained in:
commit
4eb31d1280
7 changed files with 44 additions and 55 deletions
|
@ -97,5 +97,37 @@ class AppKernel extends Kernel
|
||||||
// $container->setParameter('container.dumper.inline_class_loader', true);
|
// $container->setParameter('container.dumper.inline_class_loader', true);
|
||||||
$container->addObjectResource($this);
|
$container->addObjectResource($this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$loader->load(function (ContainerBuilder $container) {
|
||||||
|
$this->processDatabaseParameters($container);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function processDatabaseParameters(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
switch ($container->getParameter('database_driver')) {
|
||||||
|
case 'pdo_mysql':
|
||||||
|
$scheme = 'mysql';
|
||||||
|
break;
|
||||||
|
case 'pdo_pgsql':
|
||||||
|
$scheme = 'pgsql';
|
||||||
|
break;
|
||||||
|
case 'pdo_sqlite':
|
||||||
|
$scheme = 'sqlite';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \RuntimeException('Unsupported database driver: ' . $container->getParameter('database_driver'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$container->setParameter('database_scheme', $scheme);
|
||||||
|
|
||||||
|
if ('sqlite' === $scheme) {
|
||||||
|
$container->setParameter('database_name', $container->getParameter('database_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ parameters:
|
||||||
# Allows to use the live reload feature for changes in assets
|
# Allows to use the live reload feature for changes in assets
|
||||||
use_webpack_dev_server: false
|
use_webpack_dev_server: false
|
||||||
craue_config.cache_adapter.class: Craue\ConfigBundle\CacheAdapter\SymfonyCacheComponentAdapter
|
craue_config.cache_adapter.class: Craue\ConfigBundle\CacheAdapter\SymfonyCacheComponentAdapter
|
||||||
|
env(DATABASE_URL): '%database_scheme%://%database_user%:%database_password%@%database_host%:%database_port%/%database_name%?unix_socket=%database_socket%&charset=%database_charset%'
|
||||||
|
|
||||||
framework:
|
framework:
|
||||||
#esi: ~
|
#esi: ~
|
||||||
|
@ -48,15 +49,7 @@ twig:
|
||||||
# Doctrine Configuration
|
# Doctrine Configuration
|
||||||
doctrine:
|
doctrine:
|
||||||
dbal:
|
dbal:
|
||||||
driver: "%database_driver%"
|
url: '%env(resolve:DATABASE_URL)%'
|
||||||
host: "%database_host%"
|
|
||||||
port: "%database_port%"
|
|
||||||
dbname: "%database_name%"
|
|
||||||
user: "%database_user%"
|
|
||||||
password: "%database_password%"
|
|
||||||
charset: "%database_charset%"
|
|
||||||
path: "%database_path%"
|
|
||||||
unix_socket: "%database_socket%"
|
|
||||||
types:
|
types:
|
||||||
json_array: Wallabag\CoreBundle\Doctrine\JsonArrayType
|
json_array: Wallabag\CoreBundle\Doctrine\JsonArrayType
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ imports:
|
||||||
- { resource: parameters_test.yml }
|
- { resource: parameters_test.yml }
|
||||||
- { resource: services_test.yml }
|
- { resource: services_test.yml }
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
fosuser_registration: true
|
||||||
|
|
||||||
framework:
|
framework:
|
||||||
test: ~
|
test: ~
|
||||||
session:
|
session:
|
||||||
|
@ -20,14 +23,7 @@ web_profiler:
|
||||||
|
|
||||||
doctrine:
|
doctrine:
|
||||||
dbal:
|
dbal:
|
||||||
driver: "%test_database_driver%"
|
dbname_suffix: '_test' # for MySQL and PostgreSQL
|
||||||
host: "%test_database_host%"
|
|
||||||
port: "%test_database_port%"
|
|
||||||
dbname: "%test_database_name%"
|
|
||||||
user: "%test_database_user%"
|
|
||||||
password: "%test_database_password%"
|
|
||||||
charset: "%test_database_charset%"
|
|
||||||
path: "%env(TEST_DATABASE_PATH)%"
|
|
||||||
|
|
||||||
orm:
|
orm:
|
||||||
metadata_cache_driver:
|
metadata_cache_driver:
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
parameters:
|
parameters:
|
||||||
test_database_driver: pdo_sqlite
|
# Using an environment variable in order to avoid the error "attempt to write a readonly database"
|
||||||
test_database_host: 127.0.0.1
|
# when the schema is dropped then recreate
|
||||||
test_database_port: null
|
database_path: "%env(TEST_DATABASE_PATH)%"
|
||||||
test_database_name: null
|
|
||||||
test_database_user: null
|
|
||||||
test_database_password: null
|
|
||||||
test_database_path: "%env(TEST_DATABASE_PATH)%"
|
|
||||||
env(TEST_DATABASE_PATH): "%kernel.project_dir%/data/db/wallabag_test.sqlite"
|
env(TEST_DATABASE_PATH): "%kernel.project_dir%/data/db/wallabag_test.sqlite"
|
||||||
test_database_charset: utf8
|
|
||||||
fosuser_registration: true
|
|
||||||
|
|
|
@ -1,11 +1,2 @@
|
||||||
parameters:
|
parameters:
|
||||||
test_database_driver: pdo_mysql
|
env(DATABASE_URL): mysql://root:root@127.0.0.1:3306/wallabag?charset=utf8mb4
|
||||||
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_charset: utf8mb4
|
|
||||||
fosuser_registration: true
|
|
||||||
|
|
|
@ -1,11 +1,2 @@
|
||||||
parameters:
|
parameters:
|
||||||
test_database_driver: pdo_pgsql
|
env(DATABASE_URL): postgres://wallabag:wallabagrocks@localhost/wallabag?charset=utf8
|
||||||
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_charset: utf8
|
|
||||||
fosuser_registration: true
|
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
parameters:
|
parameters:
|
||||||
test_database_driver: pdo_sqlite
|
env(DATABASE_URL): sqlite://:@localhost/%env(TEST_DATABASE_PATH)%?charset=utf8
|
||||||
test_database_host: localhost
|
|
||||||
test_database_port:
|
|
||||||
test_database_name: ~
|
|
||||||
test_database_user: ~
|
|
||||||
test_database_password: ~
|
|
||||||
# Using an environment variable in order to avoid the error "attempt to write a readonly database"
|
# Using an environment variable in order to avoid the error "attempt to write a readonly database"
|
||||||
# when the schema is dropped then recreate
|
# 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"
|
env(TEST_DATABASE_PATH): "%kernel.project_dir%/data/db/wallabag_test.sqlite"
|
||||||
test_database_charset: utf8
|
|
||||||
fosuser_registration: true
|
|
||||||
|
|
Loading…
Reference in a new issue