-
-
Save mablae/0372f478b92cbfed92f4b6553c92d074 to your computer and use it in GitHub Desktop.
Revisions
-
lsmith77 revised this gist
Jul 24, 2017 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -44,8 +44,11 @@ public function testMigrations() // Test if all migrations run through $output = $this->runCommand('doctrine:migrations:migrate', ['--no-interaction']); $this->assertRegExp('/\d+ sql queries\n$/', $output); // Validate that the mapping files are correct and in sync with the database. $output = $this->runCommand('doctrine:schema:validate'); $this->assertContains('[Mapping] OK - The mapping files are correct.', $output); $this->assertContains('[Database] OK - The database schema is in sync with the mapping files.', $output); } } -
lsmith77 revised this gist
Jul 24, 2017 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,9 @@ class DoctrineMigrationTest extends WebTestCase { protected function setUp() { // Since I use LiipFunctionalTestBundle I usually use SQLite for my functional tests // so I setup a 2nd environment for testing the Migrations with the actual target DB. // Note this environment uses a dedicated schema (ie. my_db vs my_db_test) $this->environment = 'mysql_test'; /* @var \Doctrine\ORM\EntityManager */ @@ -18,13 +21,14 @@ protected function setUp() $connection = $em->getConnection(); $driver = $connection->getDriver(); if (!$driver instanceof MySQLDriver) { $this->markTestSkipped('This test requires MySQL.'); } try { $databaseName = $this->getContainer()->getParameter('database_name'); if (in_array($databaseName, $connection->getSchemaManager()->listDatabases())) { $schemaTool = new SchemaTool($em); // Drop all tables, so we can test on a clean DB $schemaTool->dropDatabase(); } } catch (\Exception $e) { @@ -37,8 +41,10 @@ protected function setUp() */ public function testMigrations() { // Test if all migrations run through $output = $this->runCommand('doctrine:migrations:migrate', ['--no-interaction']); $this->assertRegExp('/\d+ sql queries\n$/', $output); // Test if any migrations are missing $output = $this->runCommand('doctrine:migrations:diff'); $this->assertContains('No changes detected in your mapping information.', $output); } -
lsmith77 created this gist
Jul 24, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ <?php namespace AppBundle\Tests; use Doctrine\DBAL\Connection; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\DBAL\Driver\PDOMysql\Driver as MySQLDriver; class DoctrineMigrationTest extends WebTestCase { protected function setUp() { $this->environment = 'mysql_test'; /* @var \Doctrine\ORM\EntityManager */ $em = $this->getContainer()->get('doctrine')->getManager(); /** @var Connection $connection */ $connection = $em->getConnection(); $driver = $connection->getDriver(); if (!$driver instanceof MySQLDriver) { $this->markTestSkipped('This test requires a MySQL.'); } try { $databaseName = $this->getContainer()->getParameter('database_name'); if (in_array($databaseName, $connection->getSchemaManager()->listDatabases())) { $schemaTool = new SchemaTool($em); $schemaTool->dropDatabase(); } } catch (\Exception $e) { $this->fail('Could not cleanup test database for migration test: ' . $e->getMessage()); } } /** * @group mysql */ public function testMigrations() { $output = $this->runCommand('doctrine:migrations:migrate', ['--no-interaction']); $this->assertRegExp('/\d+ sql queries\n$/', $output); $output = $this->runCommand('doctrine:migrations:diff'); $this->assertContains('No changes detected in your mapping information.', $output); } }