I am working on a Symfony 2 project that runs tests with PHPUnit 4.6.2 against a test database. This test database is set up in the config files. Here are the parts regarding the doctrine configuration:
config.yml:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
config_dev.yml:
imports:
- { resource: config.yml }
config_test.yml:
imports:
- { resource: config_dev.yml }
doctrine:
dbal:
default_connection: test_sqlite
connections:
test_sqlite:
driver: pdo_sqlite
path: %kernel.cache_dir%/test.db
test_mysql:
driver: pdo_mysql
host: 192.168.56.2
port: null
name: myproject_test
user: root
password: mysupersafetestpassword
charset: UTF8
As long as I keep test_sqlite
as the value for doctrine.dbal.default_connection
in config_test.yml, the tests run fine. However, when I change this value to test_mysql
I get the following error message on every single one of my tests:
Unable to replace alias "doctrine.dbal.test_mysql_connection" with "database_connection". C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:48 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php:63 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\Compiler.php:117 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ContainerBuilder.php:614 C:\projects\myproject\app\bootstrap.php.cache:2565 C:\projects\myproject\app\bootstrap.php.cache:2344 C:\projects\myproject\app\AppKernel.php:43 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php:141 C:\projects\myproject\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\WebTestCase.php:33 C:\projects\myproject\src\mycompany\myprojectBundle\Tests\Controller\SomeControllerTest.php:23
What does this error mean and what do I need to change so I can successfully run the tests on the MySQL database?
I guess it is not the sign of a missing MySQL driver as I can e.g. run Symfony commands on the command line just fine against the production DB.