clean method doesn't support multiple connections
tlfbrito opened this issue · comments
I have multiple connections with different databases. The fixture()->clean() method only work with doctrine connection
yes, I can prove it is true what you said. I've never worked with multiple connections so I haven't had chance to implement it. If you feel power to implement it I would merge it with pleasure.
Can you give me some tips/advices to start?
Can we set a default connection? change to a specific connection to load the fixtures?
Thanks in advance ;)
... with different databases ...
Supported DBs:
- mysql
- oracle
These abstractions you can find in the folder: https://github.com/makasim/sfPhpunitPlugin/tree/master/lib/fixture/db
To write your own just follow the iterface of sfPhpunitFixtureDb
class.
... multiple connections ...
this would take more serious changes. I think it could be done via options of fixture class.
look at this class _options property https://github.com/makasim/sfPhpunitPlugin/blob/master/lib/fixture/propel/sfPhpunitFixturePropel.php
it has connection option I believe I never used it so I cannot say whether it work or not (just take it as idea).
to which options to pass you can define by overwriting the _initFixture
method a test case. the test case should extend sfBasePhpunitTestCase
As I don't have any problems with the fixtures loading...
The quickest solution was to create a fullClean that will clean all tables in each connection.
public function fullClean()
{
foreach(Doctrine_Manager::getInstance()->getConnections() as $connection){
$conn = $connection->getDbh();
$factory = new sfPhpunitFixtureDbMysql($connection->getDbh());
$factory->clean();
}
return $this;
}
If I create a pull request do you merge it?
I think I could do it.