|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use AlwaysOpen\MigrationSnapshot\Commands\MigrateDumpCommand; |
3 | 4 | use AlwaysOpen\MigrationSnapshot\Tests\TestCase;
|
4 | 5 |
|
5 | 6 | class MigrateDumpTest extends TestCase
|
@@ -32,4 +33,36 @@ public function test_dump_callsAfterDumpClosure()
|
32 | 33 | $schema_sql = file_get_contents($this->schemaSqlPath);
|
33 | 34 | $this->assertStringNotContainsString('/*', $schema_sql);
|
34 | 35 | }
|
| 36 | + |
| 37 | + public function test_dumpWithData() |
| 38 | + { |
| 39 | + if (!file_exists($this->schemaSqlDirectory)) { |
| 40 | + mkdir($this->schemaSqlDirectory, 0755); |
| 41 | + } |
| 42 | + |
| 43 | + file_put_contents($this->schemaSqlPath, 'Line that should not exist 1' . PHP_EOL); |
| 44 | + file_put_contents($this->schemaSqlPath, 'Line that should not exist 2', FILE_APPEND); |
| 45 | + |
| 46 | + $dataSqlPath = MigrateDumpCommand::getDataSqlPath( |
| 47 | + $this->app['config']->get('database.connections.' . $this->dbDefault . '.driver') |
| 48 | + ); |
| 49 | + |
| 50 | + file_put_contents($dataSqlPath, 'Line that should not exist 1' . PHP_EOL); |
| 51 | + file_put_contents($dataSqlPath, 'Line that should not exist 2', FILE_APPEND); |
| 52 | + |
| 53 | + $this->createTestTablesWithoutMigrate(); |
| 54 | + $result = \Artisan::call('migrate:dump', ['--include-data' => true]); |
| 55 | + $this->assertEquals(0, $result); |
| 56 | + $this->assertDirectoryExists($this->schemaSqlDirectory); |
| 57 | + |
| 58 | + $this->assertFileExists($this->schemaSqlPath); |
| 59 | + $result_sql = file_get_contents($this->schemaSqlPath); |
| 60 | + $this->assertStringNotContainsString('Line that should not exist 1', $result_sql); |
| 61 | + $this->assertStringNotContainsString('Line that should not exist 2', $result_sql); |
| 62 | + |
| 63 | + $this->assertFileExists($dataSqlPath); |
| 64 | + $result_data = file_get_contents($dataSqlPath); |
| 65 | + $this->assertStringNotContainsString('Line that should not exist 1', $result_data); |
| 66 | + $this->assertStringNotContainsString('Line that should not exist 2', $result_data); |
| 67 | + } |
35 | 68 | }
|
0 commit comments