-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config/migration-snapshot.php): Add
after-dump
closure. (#14)
* feat(config/migration-snapshot.php): Add `after-dump` closure. * fix(MigrateDumpTest): Remove trailing comma for compatibility with PHP 7.2.
- Loading branch information
1 parent
47aeadd
commit e61cd5b
Showing
3 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
use OrisIntel\MigrationSnapshot\Commands\MigrateDumpCommand; | ||
use OrisIntel\MigrationSnapshot\Tests\TestCase; | ||
|
||
class MigrateDumpTest extends TestCase | ||
{ | ||
protected function getEnvironmentSetUp($app) | ||
{ | ||
parent::getEnvironmentSetUp($app); | ||
$app['config']->set( | ||
'migration-snapshot.after-dump', | ||
function ($schema_sql_path, $data_sql_path) { | ||
file_put_contents( | ||
$schema_sql_path, | ||
preg_replace( | ||
'~^/\*.*\*/;?[\r\n]+~mu', // Remove /**/ comments. | ||
'', | ||
file_get_contents($schema_sql_path) | ||
) | ||
); | ||
} | ||
); | ||
} | ||
|
||
public function test_dump_callsAfterDumpClosure() | ||
{ | ||
$this->createTestTablesWithoutMigrate(); | ||
// TODO: Fix inclusion of `, ['--quiet' => true]` here breaking test. | ||
$result = \Artisan::call('migrate:dump'); | ||
$this->assertEquals(0, $result); | ||
|
||
$schema_sql = file_get_contents( | ||
database_path() . MigrateDumpCommand::SCHEMA_SQL_PATH_SUFFIX | ||
); | ||
$this->assertNotContains('/*', $schema_sql); | ||
} | ||
} |