Created
October 9, 2015 10:17
-
-
Save damienalexandre/944e8856e223a6ea9063 to your computer and use it in GitHub Desktop.
Test doctrine schema automatically for missing / broken migrations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Tests; | |
use Doctrine\ORM\Tools\SchemaTool; | |
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | |
/** | |
* Use Doctrine default entity manager and compare it's metadata to the actual database schema. | |
* | |
* @author [email protected] | |
*/ | |
class DatabaseSchemaTest extends KernelTestCase | |
{ | |
protected function setUp() | |
{ | |
self::bootKernel(); | |
} | |
public function testSchemaIsUpToDate() | |
{ | |
$em = static::$kernel->getContainer()->get('doctrine')->getManager(); | |
$metadata = $em->getMetadataFactory()->getAllMetadata(); | |
if (empty($metadata)) { | |
$this->markTestSkipped("No database mapping found."); | |
} | |
$schemaTool = new SchemaTool($em); | |
$sqls = $schemaTool->getUpdateSchemaSql($metadata, true); | |
$this->assertEmpty($sqls); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment