File tree 2 files changed +33
-4
lines changed
2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ public static function fromArray(array $data): self
27
27
$ source = require realpath (__DIR__ .'/../../config/backup.php ' );
28
28
29
29
return new self (
30
- backup: BackupConfig::fromArray (array_merge ($ source ['backup ' ], $ data ['backup ' ])),
31
- notifications: NotificationsConfig::fromArray (array_merge ($ source ['notifications ' ], $ data ['notifications ' ])),
32
- monitoredBackups: MonitoredBackupsConfig::fromArray ($ data ['monitor_backups ' ] ?? $ source ['notifications ' ]),
33
- cleanup: CleanupConfig::fromArray (array_merge ($ source ['cleanup ' ], $ data ['cleanup ' ]))
30
+ backup: BackupConfig::fromArray (array_merge ($ source ['backup ' ], $ data ['backup ' ] ?? [] )),
31
+ notifications: NotificationsConfig::fromArray (array_merge ($ source ['notifications ' ], $ data ['notifications ' ] ?? [] )),
32
+ monitoredBackups: MonitoredBackupsConfig::fromArray ($ data ['monitor_backups ' ] ?? $ source ['monitor_backups ' ]),
33
+ cleanup: CleanupConfig::fromArray (array_merge ($ source ['cleanup ' ], $ data ['cleanup ' ] ?? [] ))
34
34
);
35
35
}
36
36
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Spatie \Backup \Config \Config ;
4
+ use Spatie \Backup \Config \BackupConfig ;
5
+ use Spatie \Backup \Config \NotificationsConfig ;
6
+ use Spatie \Backup \Config \MonitoredBackupsConfig ;
7
+ use Spatie \Backup \Config \CleanupConfig ;
8
+
9
+ beforeEach (function () {
10
+ config ()->set ('backup ' , []);
11
+ });
12
+
13
+ it ('returns default backup config if no backup config file exist ' , function () {
14
+ $ config = Config::fromArray (config ('backup ' ));
15
+
16
+ expect ($ config ->backup )->toBeInstanceOf (BackupConfig::class);
17
+ expect ($ config ->notifications )->toBeInstanceOf (NotificationsConfig::class);
18
+ expect ($ config ->monitoredBackups )->toBeInstanceOf (MonitoredBackupsConfig::class);
19
+ expect ($ config ->cleanup )->toBeInstanceOf (CleanupConfig::class);
20
+ });
21
+
22
+ it ('returns a merged backup config made with minimal config and default config file ' , function () {
23
+ config ()->set ('backup.backup.name ' , 'foo ' );
24
+
25
+ $ config = Config::fromArray (config ('backup ' ));
26
+
27
+ expect ($ config ->backup )->toBeInstanceOf (BackupConfig::class);
28
+ expect ($ config ->backup ->name )->toBe ('foo ' );
29
+ });
You can’t perform that action at this time.
0 commit comments