Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Modify schema update to now simply delete the whole db #197

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Nek-
Copy link
Contributor

@Nek- Nek- commented Apr 17, 2016

This is about #195

Q A
BC Break? yes
new feature? no
bug fix? yes
test pass? not testable with phpspec (the old method was not either)
fixed ticket? #195

Please notice that I could make another tag like @reset-database which will not break the compatibiity. (it breaks on schema generation, after this patch you need to generate the schema before your test suite)

}
foreach ($this->getEntityManagers() as $entityManager) {
$purger->setEntityManager($entityManager);
$purger->purge();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so in that case, please remove useless use Doctrine\ORM\Tools\SchemaTool; 😉

@ioleo
Copy link

ioleo commented Jun 7, 2016

Is this going to be merged?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants