From 39b477ce53ff3ca731a1c8b70055a27f1bf2ae5f Mon Sep 17 00:00:00 2001 From: NiroDeveloper Date: Wed, 22 Jan 2025 09:05:54 +0100 Subject: [PATCH] Fix temp directory config path and add unit test --- src/BackupServiceProvider.php | 2 +- tests/Config/ConfigTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/BackupServiceProvider.php b/src/BackupServiceProvider.php index 3771b62c..92288ab2 100644 --- a/src/BackupServiceProvider.php +++ b/src/BackupServiceProvider.php @@ -50,7 +50,7 @@ public function packageRegistered(): void $this->app->singleton(ConsoleOutput::class); $this->app->bind(CleanupStrategy::class, config('backup.cleanup.strategy')); - $this->app->bind('backup-temporary-project', fn () => new TemporaryDirectory(config('backup.temporary_directory') ?? storage_path('app/backup-temp'))); + $this->app->bind('backup-temporary-project', fn () => new TemporaryDirectory(config('backup.backup.temporary_directory') ?? storage_path('app/backup-temp'))); $this->registerDiscordChannel(); diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index 8ebb3d92..d9b4f08b 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -27,3 +27,11 @@ expect($config->backup)->toBeInstanceOf(BackupConfig::class); expect($config->backup->name)->toBe('foo'); }); + +it('receives temp directory as configured from service container', function () { + config()->set('backup.backup.temporary_directory', '/foo'); + + $tempDirectory = app()->make('backup-temporary-project'); + + expect($tempDirectory->path())->toBe('/foo'); +});