@@ -17,7 +17,7 @@ public function test_restore_into_cwd_by_default_with_all_content_types()
17
17
$ this ->assertEquals (0 , mysqli_num_rows ($ result ));
18
18
19
19
$ zipFile = $ this ->buildZip (function (\ZipArchive $ zip ) {
20
- $ zip ->addFromString ('.env ' , "APP_KEY=abc123 \nAPP_URL=https://example.com " );
20
+ $ zip ->addFromString ('.env ' , "APP_KEY=abc123 \nAPP_URL=https://restore. example.com " );
21
21
$ zip ->addFromString ('public/uploads/test.txt ' , 'hello-public-uploads ' );
22
22
$ zip ->addFromString ('storage/uploads/test.txt ' , 'hello-storage-uploads ' );
23
23
$ zip ->addFromString ('themes/test.txt ' , 'hello-themes ' );
@@ -29,15 +29,17 @@ public function test_restore_into_cwd_by_default_with_all_content_types()
29
29
30
30
$ result = $ this ->runCommand ('restore ' , [
31
31
'backup-zip ' => $ zipFile ,
32
- ], ['yes ' , '1 ' ]);
32
+ ], ['yes ' , '1 ' ]); // This restore uses the existing (Non-backup) APP_URL
33
33
34
+ $ result ->dumpError ();
34
35
$ result ->assertSuccessfulExit ();
35
36
$ result ->assertStdoutContains ('✔ .env Config File ' );
36
37
$ result ->assertStdoutContains ('✔ Themes Folder ' );
37
38
$ result ->assertStdoutContains ('✔ Public File Uploads ' );
38
39
$ result ->assertStdoutContains ('✔ Private File Uploads ' );
39
40
$ result ->assertStdoutContains ('✔ Database Dump ' );
40
41
$ result ->assertStdoutContains ('Restore operation complete! ' );
42
+ $ result ->assertStdoutContains ('App URL change made, updating database with URL change ' );
41
43
42
44
$ result = $ mysql ->query ('SELECT * FROM zz_testing where names = \'barry \'; ' );
43
45
$ this ->assertEquals (1 , mysqli_num_rows ($ result ));
@@ -47,14 +49,40 @@ public function test_restore_into_cwd_by_default_with_all_content_types()
47
49
$ this ->assertStringEqualsFile ('/var/www/bookstack-restore/public/uploads/test.txt ' , 'hello-public-uploads ' );
48
50
$ this ->assertStringEqualsFile ('/var/www/bookstack-restore/storage/uploads/test.txt ' , 'hello-storage-uploads ' );
49
51
$ this ->assertStringEqualsFile ('/var/www/bookstack-restore/themes/test.txt ' , 'hello-themes ' );
52
+
50
53
$ env = file_get_contents ('/var/www/bookstack-restore/.env ' );
51
54
$ this ->assertStringContainsString ('APP_KEY=abc123 ' , $ env );
52
- $ this ->assertStringContainsString ('APP_URL=https://example.com ' , $ env );
55
+ $ this ->assertStringNotContainsString ('APP_URL=https://restore.example.com ' , $ env );
56
+ $ this ->assertStringContainsString ('APP_URL="https://example.com" ' , $ env );
53
57
54
58
$ mysql ->query ("DROP TABLE zz_testing; " );
55
59
exec ('rm -rf /var/www/bookstack-restore ' );
56
60
}
57
61
62
+ public function test_restore_using_backup_env_url ()
63
+ {
64
+ $ zipFile = $ this ->buildZip (function (\ZipArchive $ zip ) {
65
+ $ zip ->addFromString ('.env ' , "APP_KEY=abc123 \nAPP_URL=https://restore.example.com " );
66
+ });
67
+
68
+ exec ('cp -r /var/www/bookstack /var/www/bookstack-restore-backup-env ' );
69
+ chdir ('/var/www/bookstack-restore-backup-env ' );
70
+
71
+ $ result = $ this ->runCommand ('restore ' , [
72
+ 'backup-zip ' => $ zipFile ,
73
+ ], ['yes ' , '0 ' ]); // This restore uses the old (Backup) APP_URL
74
+
75
+ $ result ->assertSuccessfulExit ();
76
+ $ result ->assertStdoutContains ('✔ .env Config File ' );
77
+ $ result ->assertStdoutContains ('Restore operation complete! ' );
78
+
79
+ $ env = file_get_contents ('/var/www/bookstack-restore-backup-env/.env ' );
80
+ $ this ->assertStringContainsString ('APP_KEY=abc123 ' , $ env );
81
+ $ this ->assertStringContainsString ('APP_URL="https://restore.example.com" ' , $ env );
82
+
83
+ exec ('rm -rf /var/www/bookstack-restore-backup-env ' );
84
+ }
85
+
58
86
public function test_command_fails_on_zip_with_no_expected_contents ()
59
87
{
60
88
$ zipFile = $ this ->buildZip (function (\ZipArchive $ zip ) {
0 commit comments