Modify schema update to now simply delete the whole db#197
Modify schema update to now simply delete the whole db#197Nek- wants to merge 2 commits intoKnpLabs:masterfrom
Conversation
| } | ||
| foreach ($this->getEntityManagers() as $entityManager) { | ||
| $purger->setEntityManager($entityManager); | ||
| $purger->purge(); |
There was a problem hiding this comment.
This purger requires to build schema manually before running tests. To prevent this, you can reset schema once, maybe something like:
/**
* @var bool
*/
private $databaseReady = false;
// ...
if (!$this->databaseReady) {
$metadata = $entityManager->getMetadataFactory()->getAllMetadata();
$tool = new SchemaTool($this->entityManager);
$tool->dropSchema($metadata);
$tool->createSchema($metadata);
$this->databaseReady = true;
}There was a problem hiding this comment.
I understand it's a bcbreak. But IMO the good thing to do is to build schema in a different task than purging the database.
It's possible the database is already good when you run your tests on your computer. In this case rebuilding the database is not desired.
There was a problem hiding this comment.
Please note also that your change is a bc break too as it suggest the database is build only once, and if the test needs a real schema reset the second time, it will not be executed.
There was a problem hiding this comment.
OK so in that case, please remove useless use Doctrine\ORM\Tools\SchemaTool; 😉
|
Is this going to be merged? |
This is about #195
Please notice that I could make another tag like
@reset-databasewhich will not break the compatibiity. (it breaks on schema generation, after this patch you need to generate the schema before your test suite)