LiipFunctionalTestBundle
LiipFunctionalTestBundle copied to clipboard
WebTestCase::loadFixtureFiles with append=false using ODM fails
When attempting to use \Liip\FunctionalTestBundle\Test\WebTestCase::loadFixtureFiles()
passing in append=false
, I encountered an error. I believe it has to do with detection of the DB platform as shown in L382-L394.
My workaround, presently, is as follows:
/**
* @inheritDoc
*/
public function loadFixtureFiles(array $paths = [], $append = false, $omName = null, $registryName = 'doctrine')
{
$om = $this->getObjectManager($omName, $registryName);
if ($append == false && ($om instanceof DocumentManager)) {
$sm = $om->getSchemaManager();
$sm->dropDatabases();
$sm->createDatabases();
}
parent::loadFixtureFiles($paths, true, $omName, $registryName);
}
Not sure if that would be the ideal approach, or if there's a better platform agnostic way of determining which class methods need to be called for a reset. Just wanted to call it out for a future release!
its easier to review if you just open a PR
The snag here is that you can't necessarily take the above mentioned approach for the method, since this bundle doesn't have concrete dependencies on doctrine/mongodb-odm
.
You could do a method_exists($om, 'getSchemaManager')
or is_a($om, 'Doctrine\ODM\MongoDB\DocumentManager')
check, but both approaches feel super brittle, so I'm not sure what would be the best tactic here without requiring any further dependencies.
@ReservedDeveloper can't we use something like if ('ODM' === $type) {
for detecting ODM?
@alexislefebvre no .. the type will be specific to the ODM .. but we can check for 'ORM' !== $type