From 7ab5eb9508921d84b4b4ec84a59135d536da748e Mon Sep 17 00:00:00 2001 From: adev Date: Mon, 15 May 2017 20:47:59 +0200 Subject: Isolated tests Use https://github.com/dmaicher/doctrine-test-bundle to have test isolation. --- app/AppKernel.php | 4 ++++ app/config/config_test.yml | 3 ++- app/config/parameters_test.yml | 3 ++- app/config/tests/parameters_test.mysql.yml | 1 + app/config/tests/parameters_test.pgsql.yml | 1 + app/config/tests/parameters_test.sqlite.yml | 5 ++++- 6 files changed, 14 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/AppKernel.php b/app/AppKernel.php index b9293498..c50783a6 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -48,6 +48,10 @@ class AppKernel extends Kernel $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); + + if ('test' === $this->getEnvironment()) { + $bundles[] = new DAMA\DoctrineTestBundle\DAMADoctrineTestBundle(); + } } return $bundles; diff --git a/app/config/config_test.yml b/app/config/config_test.yml index f5e2c25e..c620c359 100644 --- a/app/config/config_test.yml +++ b/app/config/config_test.yml @@ -29,7 +29,8 @@ doctrine: user: "%test_database_user%" password: "%test_database_password%" charset: "%test_database_charset%" - path: "%test_database_path%" + path: "%env(TEST_DATABASE_PATH)%" + orm: metadata_cache_driver: type: service diff --git a/app/config/parameters_test.yml b/app/config/parameters_test.yml index 5f2e25bb..010785e6 100644 --- a/app/config/parameters_test.yml +++ b/app/config/parameters_test.yml @@ -5,5 +5,6 @@ parameters: test_database_name: null test_database_user: null test_database_password: null - test_database_path: '%kernel.root_dir%/../data/db/wallabag_test.sqlite' + test_database_path: "%env(TEST_DATABASE_PATH)%" + env(TEST_DATABASE_PATH): "%kernel.root_dir%/../data/db/wallabag_test.sqlite" test_database_charset: utf8 diff --git a/app/config/tests/parameters_test.mysql.yml b/app/config/tests/parameters_test.mysql.yml index bca2d466..36b227fb 100644 --- a/app/config/tests/parameters_test.mysql.yml +++ b/app/config/tests/parameters_test.mysql.yml @@ -6,4 +6,5 @@ parameters: test_database_user: root test_database_password: ~ test_database_path: ~ + env(TEST_DATABASE_PATH): ~ test_database_charset: utf8mb4 diff --git a/app/config/tests/parameters_test.pgsql.yml b/app/config/tests/parameters_test.pgsql.yml index 3e18d4a0..60f51df6 100644 --- a/app/config/tests/parameters_test.pgsql.yml +++ b/app/config/tests/parameters_test.pgsql.yml @@ -6,4 +6,5 @@ parameters: test_database_user: travis test_database_password: ~ test_database_path: ~ + env(TEST_DATABASE_PATH): ~ test_database_charset: utf8 diff --git a/app/config/tests/parameters_test.sqlite.yml b/app/config/tests/parameters_test.sqlite.yml index b8a5f41a..5c731bf5 100644 --- a/app/config/tests/parameters_test.sqlite.yml +++ b/app/config/tests/parameters_test.sqlite.yml @@ -5,5 +5,8 @@ parameters: test_database_name: ~ test_database_user: ~ test_database_password: ~ - test_database_path: "%kernel.root_dir%/../data/db/wallabag_test.sqlite" + # Using an environnement 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.root_dir%/../data/db/wallabag_test.sqlite" test_database_charset: utf8 -- cgit v1.2.3