File tree 2 files changed +22
-3
lines changed
2 files changed +22
-3
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 dirname (__DIR__ , 2 ).'/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 ' ] ?? [])),
30
+ backup: BackupConfig::fromArray (array_replace_recursive ($ source ['backup ' ], $ data ['backup ' ] ?? [])),
31
+ notifications: NotificationsConfig::fromArray (array_replace_recursive ($ source ['notifications ' ], $ data ['notifications ' ] ?? [])),
32
32
monitoredBackups: MonitoredBackupsConfig::fromArray ($ data ['monitor_backups ' ] ?? $ source ['monitor_backups ' ]),
33
- cleanup: CleanupConfig::fromArray (array_merge ($ source ['cleanup ' ], $ data ['cleanup ' ] ?? []))
33
+ cleanup: CleanupConfig::fromArray (array_replace_recursive ($ source ['cleanup ' ], $ data ['cleanup ' ] ?? []))
34
34
);
35
35
}
36
36
}
Original file line number Diff line number Diff line change 3
3
use Spatie \Backup \Config \BackupConfig ;
4
4
use Spatie \Backup \Config \CleanupConfig ;
5
5
use Spatie \Backup \Config \Config ;
6
+ use Spatie \Backup \Config \DestinationConfig ;
6
7
use Spatie \Backup \Config \MonitoredBackupsConfig ;
7
8
use Spatie \Backup \Config \NotificationsConfig ;
8
9
35
36
36
37
expect ($ tempDirectory ->path ())->toBe ('/foo ' );
37
38
});
39
+
40
+ it ('merges the published config file with package config file ' , function () {
41
+ config ()->set ('backup.backup.destination ' , []);
42
+
43
+ $ config = Config::fromArray (config ('backup ' ));
44
+
45
+ expect ($ config ->backup ->destination )->toBeInstanceOf (DestinationConfig::class);
46
+ expect ($ config ->backup ->destination ->compressionMethod )->toBe (-1 );
47
+ });
48
+
49
+ it ('merges the published config file with package config file and preserve published config values ' , function () {
50
+ config ()->set ('backup.backup.destination ' , ['compression_method ' => 2 ]);
51
+
52
+ $ config = Config::fromArray (config ('backup ' ));
53
+
54
+ expect ($ config ->backup ->destination )->toBeInstanceOf (DestinationConfig::class);
55
+ expect ($ config ->backup ->destination ->compressionMethod )->toBe (2 );
56
+ });
You can’t perform that action at this time.
0 commit comments