@@ -17,26 +17,29 @@ class HostingSubscriptionBackupTest extends ActionTestCase
17
17
{
18
18
public function testFullBackup ()
19
19
{
20
- $ this ->_createHostingSubscription ();
20
+ $ chs = $ this ->_createHostingSubscription ();
21
21
22
22
Artisan::call ('phyre:run-hosting-subscriptions-backup ' );
23
23
24
- $ findLastBackup = HostingSubscriptionBackup::orderBy ('id ' , 'asc ' )->first ();
24
+ $ findLastBackup = HostingSubscriptionBackup::where ('hosting_subscription_id ' , $ chs ['hostingSubscriptionId ' ])
25
+ ->first ();
26
+
25
27
$ this ->assertNotEmpty ($ findLastBackup );
26
28
$ this ->assertNotEmpty ($ findLastBackup ->id );
27
29
$ this ->assertNotEmpty ($ findLastBackup ->created_at );
28
30
$ this ->assertSame ($ findLastBackup ->backup_type , 'full ' );
29
31
30
32
$ backupFinished = false ;
31
- for ($ i = 0 ; $ i < 100 ; $ i ++) {
32
- $ findLastBackup = HostingSubscriptionBackup::orderBy ('id ' , ' desc ' )->first ();
33
+ for ($ i = 0 ; $ i < 50 ; $ i ++) {
34
+ $ findLastBackup = HostingSubscriptionBackup::where ('id ' , $ findLastBackup -> id )->first ();
33
35
$ findLastBackup ->checkBackup ();
34
36
if ($ findLastBackup ->status == BackupStatus::Completed) {
35
37
$ backupFinished = true ;
36
38
break ;
37
39
}
38
40
sleep (1 );
39
41
}
42
+
40
43
$ this ->assertTrue ($ backupFinished );
41
44
$ this ->assertSame ($ findLastBackup ->status , BackupStatus::Completed);
42
45
$ this ->assertNotEmpty ($ findLastBackup ->filepath );
@@ -46,23 +49,25 @@ public function testFullBackup()
46
49
$ checkCronJob = $ backup ->checkCronJob ();
47
50
$ this ->assertTrue ($ checkCronJob );
48
51
49
- $ this ->_createHostingSubscription ();
52
+ $ chs = $ this ->_createHostingSubscription ();
50
53
51
54
$ backup = new HostingSubscriptionBackup ();
52
55
$ backup ->backup_type = 'full ' ;
56
+ $ backup ->hosting_subscription_id = $ chs ['hostingSubscriptionId ' ];
53
57
$ backup ->save ();
54
58
55
59
$ backupId = $ backup ->id ;
56
60
57
61
$ findBackup = false ;
58
62
$ backupCompleted = false ;
59
- for ($ i = 0 ; $ i < 100 ; $ i ++) {
63
+ for ($ i = 0 ; $ i < 10 ; $ i ++) {
60
64
$ findBackup = HostingSubscriptionBackup::where ('id ' , $ backupId )->first ();
61
- $ status = $ findBackup ->checkBackup ();
62
- dump ($ status );
63
- if ($ findBackup ->status == BackupStatus::Completed) {
64
- $ backupCompleted = true ;
65
- break ;
65
+ if ($ findBackup ) {
66
+ $ status = $ findBackup ->checkBackup ();
67
+ if ($ findBackup ->status == BackupStatus::Completed) {
68
+ $ backupCompleted = true ;
69
+ break ;
70
+ }
66
71
}
67
72
sleep (1 );
68
73
}
@@ -106,5 +111,11 @@ private function _createHostingSubscription()
106
111
$ hostingSubscription ->hosting_plan_id = $ hostingPlan ->id ;
107
112
$ hostingSubscription ->domain = 'unit-backup-test ' . time () . '.com ' ;
108
113
$ hostingSubscription ->save ();
114
+
115
+ return [
116
+ 'customerId ' => $ customer ->id ,
117
+ 'hostingPlanId ' => $ hostingPlan ->id ,
118
+ 'hostingSubscriptionId ' => $ hostingSubscription ->id ,
119
+ ];
109
120
}
110
121
}
0 commit comments