@@ -118,31 +118,31 @@ public function test_generate_2_single_table_backup_all_table_data()
118
118
$ fatherTable = 'fathers ' ;
119
119
$ sonTable = 'sons ' ;
120
120
121
- Father::create ([
121
+ $ father = Father::create ([
122
122
'id ' => 1 ,
123
123
'first_name ' => 'Ahmed ' ,
124
124
'last_name ' => 'Saleh ' ,
125
125
'email ' => 'father@email.com ' ,
126
126
]);
127
127
128
128
Son::create ([
129
- 'father_id ' => 1 ,
129
+ 'father_id ' => $ father -> id ,
130
130
]);
131
131
132
132
BackupTables::generateBackup ($ fatherTable );
133
133
134
134
$ currentDateTime = now ()->format ('Y_m_d_H_i_s ' );
135
- $ newTableName = $ fatherTable . '_backup_ ' . $ currentDateTime ;
136
- $ newTableName2 = $ sonTable . '_backup_ ' . $ currentDateTime ;
135
+ $ newFatherTable = $ fatherTable . '_backup_ ' . $ currentDateTime ;
136
+ $ newSonTable = $ sonTable . '_backup_ ' . $ currentDateTime ;
137
137
138
- $ this ->assertTrue (Schema::hasTable ($ newTableName ));
138
+ $ this ->assertTrue (Schema::hasTable ($ newFatherTable ));
139
139
140
- $ this ->assertEquals (DB ::table ('fathers ' )->value ('first_name ' ), DB ::table ($ newTableName )->value ('first_name ' ));
141
- $ this ->assertEquals (DB ::table ('fathers ' )->value ('email ' ), DB ::table ($ newTableName )->value ('email ' ));
140
+ $ this ->assertEquals (DB ::table ('fathers ' )->value ('first_name ' ), DB ::table ($ newFatherTable )->value ('first_name ' ));
141
+ $ this ->assertEquals (DB ::table ('fathers ' )->value ('email ' ), DB ::table ($ newFatherTable )->value ('email ' ));
142
142
143
143
BackupTables::generateBackup ($ sonTable );
144
- $ this ->assertTrue (Schema::hasTable ($ newTableName2 ));
145
- $ this ->assertEquals (DB ::table ('sons ' )->value ('father_id ' ), DB ::table ($ newTableName2 )->value ('father_id ' ));
144
+ $ this ->assertTrue (Schema::hasTable ($ newSonTable ));
145
+ $ this ->assertEquals (DB ::table ('sons ' )->value ('father_id ' ), DB ::table ($ newSonTable )->value ('father_id ' ));
146
146
}
147
147
148
148
//public function test_generate_multiple_table_backup()
0 commit comments