-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: father_id make it dynamically in test_generate_2_single_table_ba…
…ckup_all_table_data
- Loading branch information
1 parent
fd80ebe
commit ecf356e
Showing
2 changed files
with
17 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,31 +118,31 @@ public function test_generate_2_single_table_backup_all_table_data() | |
$fatherTable = 'fathers'; | ||
$sonTable = 'sons'; | ||
|
||
Father::create([ | ||
$father = Father::create([ | ||
'id' => 1, | ||
'first_name' => 'Ahmed', | ||
'last_name' => 'Saleh', | ||
'email' => '[email protected]', | ||
]); | ||
|
||
Son::create([ | ||
'father_id' => 1, | ||
'father_id' => $father->id, | ||
]); | ||
|
||
BackupTables::generateBackup($fatherTable); | ||
|
||
$currentDateTime = now()->format('Y_m_d_H_i_s'); | ||
$newTableName = $fatherTable . '_backup_' . $currentDateTime; | ||
$newTableName2 = $sonTable . '_backup_' . $currentDateTime; | ||
$newFatherTable = $fatherTable . '_backup_' . $currentDateTime; | ||
$newSonTable = $sonTable . '_backup_' . $currentDateTime; | ||
|
||
$this->assertTrue(Schema::hasTable($newTableName)); | ||
$this->assertTrue(Schema::hasTable($newFatherTable)); | ||
|
||
$this->assertEquals(DB::table('fathers')->value('first_name'), DB::table($newTableName)->value('first_name')); | ||
$this->assertEquals(DB::table('fathers')->value('email'), DB::table($newTableName)->value('email')); | ||
$this->assertEquals(DB::table('fathers')->value('first_name'), DB::table($newFatherTable)->value('first_name')); | ||
$this->assertEquals(DB::table('fathers')->value('email'), DB::table($newFatherTable)->value('email')); | ||
|
||
BackupTables::generateBackup($sonTable); | ||
$this->assertTrue(Schema::hasTable($newTableName2)); | ||
$this->assertEquals(DB::table('sons')->value('father_id'), DB::table($newTableName2)->value('father_id')); | ||
$this->assertTrue(Schema::hasTable($newSonTable)); | ||
$this->assertEquals(DB::table('sons')->value('father_id'), DB::table($newSonTable)->value('father_id')); | ||
} | ||
|
||
//public function test_generate_multiple_table_backup() | ||
|