Skip to content

Commit

Permalink
Add boot method with config file in the test bootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz committed Dec 27, 2023
1 parent c7a6b97 commit 5ec0cf4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/app/Bootloader/BlogBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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([
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Attribute/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

0 comments on commit 5ec0cf4

Please sign in to comment.