From 5ec0cf4e6f31d5163beb3d597813b5937591a7e8 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 27 Dec 2023 16:25:49 +0200 Subject: [PATCH] Add boot method with config file in the test bootloader --- tests/app/Bootloader/BlogBootloader.php | 8 ++++++++ tests/src/Attribute/ConfigTest.php | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/app/Bootloader/BlogBootloader.php b/tests/app/Bootloader/BlogBootloader.php index bef9242..8f992fb 100644 --- a/tests/app/Bootloader/BlogBootloader.php +++ b/tests/app/Bootloader/BlogBootloader.php @@ -5,6 +5,7 @@ namespace Spiral\Testing\Tests\App\Bootloader; use Spiral\Boot\Bootloader\Bootloader; +use Spiral\Storage\Config\StorageConfig; use Spiral\Testing\Tests\App\Repositories\ArrayPostRepository; use Spiral\Testing\Tests\App\Repositories\PostRepositoryInterface; use Spiral\Testing\Tests\App\Services\BlogService; @@ -20,6 +21,13 @@ final class BlogBootloader extends Bootloader PostRepositoryInterface::class => [self::class, 'initPostRepository'] ]; + /** + * The configuration file should be modified by an attribute BEFORE it's used in the boot method + */ + public function boot(StorageConfig $config): void + { + } + protected function initPostRepository(): PostRepositoryInterface { return new ArrayPostRepository([ diff --git a/tests/src/Attribute/ConfigTest.php b/tests/src/Attribute/ConfigTest.php index 662fcdb..693ee06 100644 --- a/tests/src/Attribute/ConfigTest.php +++ b/tests/src/Attribute/ConfigTest.php @@ -24,11 +24,11 @@ public function testReplaceUsingAttribute(): void } #[Config('storage.default', 'replaced')] - #[Config('storage.servers.static.adapter', 'test')] + #[Config('storage.servers.static.directory', 'test')] public function testMultipleAttributes(): void { $config = $this->getConfig(StorageConfig::CONFIG); $this->assertSame('replaced', $config['default']); - $this->assertSame('test', $config['servers']['static']['adapter']); + $this->assertSame('test', $config['servers']['static']['directory']); } }