@@ -15,6 +15,7 @@ class BackupTableCommandTest extends TestCase
15
15
/** @test */
16
16
public function it_can_backup_a_table ()
17
17
{
18
+ $ now = now ();
18
19
Schema::create ('test_table ' , function ($ table ) {
19
20
$ table ->bigIncrements ('id ' );
20
21
$ table ->string ('name ' );
@@ -24,14 +25,15 @@ public function it_can_backup_a_table()
24
25
$ this ->artisan ('backup:tables ' , ['targets ' => 'test_table ' ])
25
26
->assertExitCode (BackupTableCommand::SUCCESS );
26
27
27
- $ backupTablePattern = 'test_table_backup_ ' .now () ->format ('Y_m_d_H_i_s ' );
28
+ $ backupTablePattern = 'test_table_backup_ ' .$ now ->format ('Y_m_d_H_i_s ' );
28
29
29
30
$ this ->assertTrue (Schema::hasTable ($ backupTablePattern ));
30
31
}
31
32
32
33
/** @test */
33
34
public function it_can_backup_a_table_by_classname ()
34
35
{
36
+ $ now = now ();
35
37
Schema::create ('test_table ' , function ($ table ) {
36
38
$ table ->bigIncrements ('id ' );
37
39
$ table ->string ('name ' );
@@ -41,7 +43,7 @@ public function it_can_backup_a_table_by_classname()
41
43
$ this ->artisan (BackupTableCommand::class, ['targets ' => 'test_table ' ])
42
44
->assertExitCode (BackupTableCommand::SUCCESS );
43
45
44
- $ backupTablePattern = 'test_table_backup_ ' .now () ->format ('Y_m_d_H_i_s ' );
46
+ $ backupTablePattern = 'test_table_backup_ ' .$ now ->format ('Y_m_d_H_i_s ' );
45
47
46
48
$ this ->assertTrue (Schema::hasTable ($ backupTablePattern ));
47
49
}
@@ -56,6 +58,7 @@ public function it_fails_when_table_does_not_exist()
56
58
/** @test */
57
59
public function it_can_backup_multiple_tables ()
58
60
{
61
+ $ now = now ();
59
62
$ tables = ['test_table_1 ' , 'test_table_2 ' ];
60
63
61
64
foreach ($ tables as $ table ) {
@@ -70,7 +73,7 @@ public function it_can_backup_multiple_tables()
70
73
->assertExitCode (BackupTableCommand::SUCCESS );
71
74
72
75
foreach ($ tables as $ table ) {
73
- $ backupTablePattern = $ table .'_backup_ ' .now () ->format ('Y_m_d_H_i_s ' );
76
+ $ backupTablePattern = $ table .'_backup_ ' .$ now ->format ('Y_m_d_H_i_s ' );
74
77
75
78
$ this ->assertTrue (Schema::hasTable ($ backupTablePattern ));
76
79
}
@@ -97,6 +100,8 @@ public function it_can_backup_multiple_models()
97
100
/** @test */
98
101
public function it_fails_when_any_table_does_not_exist_but_saves_corrected_tables ()
99
102
{
103
+ $ now = now ();
104
+
100
105
Schema::create ('existing_table ' , function ($ table ) {
101
106
$ table ->bigIncrements ('id ' );
102
107
$ table ->timestamps ();
@@ -105,8 +110,8 @@ public function it_fails_when_any_table_does_not_exist_but_saves_corrected_table
105
110
$ this ->artisan ('backup:tables ' , ['targets ' => 'existing_table ' , 'non_existent_table ' ])
106
111
->assertExitCode (BackupTableCommand::SUCCESS );
107
112
108
- $ backupExistingTablePattern = 'existing_table_backup_ ' .now () ->format ('Y_m_d_H_i_s ' );
109
- $ backupNonExistingTablePattern = 'non_existent_table_backup_ ' .now () ->format ('Y_m_d_H_i_s ' );
113
+ $ backupExistingTablePattern = 'existing_table_backup_ ' .$ now ->format ('Y_m_d_H_i_s ' );
114
+ $ backupNonExistingTablePattern = 'non_existent_table_backup_ ' .$ now ->format ('Y_m_d_H_i_s ' );
110
115
111
116
$ this ->assertTrue (Schema::hasTable ($ backupExistingTablePattern ));
112
117
0 commit comments