0
votes

I'm trying to configure Propel for unit testing. I have created a second connection for testing purposes, but I haven't been able to figure out how to make propel use it. The connection looks like this:

connectionForTests:
    adapter: mysql
    dsn: mysql:host=localhost;port=3306;dbname=code_test
    user: root
    password: root
    settings:
        charset: utf8

And I have looked at the propel docs, there's not very much information about how to get propel to actually use a different connection. Do I set an environment variable, run a function on a ConnectionFactory, or something like that?

I'm using Propel2 at dev-master, and I am not using it as a part of Symfony.

1

1 Answers

0
votes

I was able to accomplish this by doing:

$default = Propel\Runtime\Propel::getConnectionManager('default');
$test = Propel\Runtime\Propel::getConnectionManager('connectionForTests');

$config = $test->getConfiguration();
$default->setConfiguration($config);

In my PHPUnit bootstrap file.