From 04f332ac5bb89e504e5a72f45450bd815694e762 Mon Sep 17 00:00:00 2001 From: "Timo A. Hummel" Date: Sat, 12 Sep 2015 14:31:39 +0200 Subject: [PATCH] Added note about multiple database connections This is a note on how to configure multiple database connections for e.g. functional testing. --- Resources/doc/index.rst | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 440f8497..73b4830a 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -301,6 +301,46 @@ or in XML:: +Functional Tests with multiple database connections +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you write functional tests with multiple database connections using +`LiipFunctionalTestBundle`_, you can configure multiple database connections +like this: + +.. code-block:: yaml + + # app/config/config_test.yml + + doctrine: + dbal: + default_connection: %testdb% + connections: + sqlite: + driver: pdo_sqlite + path: %kernel.cache_dir%/test.db + mysql: + driver: pdo_mysql + dbname: testdb + host: localhost + user: travis + pgsql: + driver: pdo_pgsql + dbname: testdb + host: localhost + user: travis + + stof_doctrine_extensions: + default_locale: en_US + orm: + %testdb%: + tree: true + +Then you can set the environment variable ``SYMFONY__TESTDB`` to your configured +database connection, and the extensions get automatically registered for +whichever database connection you are using. + +.. _`LiipFunctionalTestBundle`: https://github.com/liip/LiipFunctionalTestBundle .. _DoctrineExtensions: http://github.com/l3pp4rd/DoctrineExtensions .. _blog: http://gediminasm.org/articles .. _documentation: http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview