Skip to content

Commit

Permalink
feat: add RegisterFacades::class and register to bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
SonyPradana committed Jun 29, 2024
1 parent 6c95f6a commit 95238a6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/System/Integrate/Bootstrap/RegisterFacades.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace System\Integrate\Bootstrap;

use System\Integrate\Application;
use System\Support\Facades\Facade;

class RegisterFacades
{
public function bootstrap(Application $app): void
{
Facade::setFacadeBase($app);
}
}
2 changes: 2 additions & 0 deletions src/System/Integrate/Console/Karnel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use System\Integrate\Application;
use System\Integrate\Bootstrap\BootProviders;
use System\Integrate\Bootstrap\ConfigProviders;
use System\Integrate\Bootstrap\RegisterFacades;
use System\Integrate\Bootstrap\RegisterProviders;
use System\Integrate\ValueObjects\CommandMap;

Expand All @@ -24,6 +25,7 @@ class Karnel
/** @var array<int, class-string> Apllication bootstrap register. */
protected array $bootstrappers = [
ConfigProviders::class,
RegisterFacades::class,
RegisterProviders::class,
BootProviders::class,
];
Expand Down
2 changes: 2 additions & 0 deletions src/System/Integrate/Http/Karnel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use System\Integrate\Application;
use System\Integrate\Bootstrap\BootProviders;
use System\Integrate\Bootstrap\ConfigProviders;
use System\Integrate\Bootstrap\RegisterFacades;
use System\Integrate\Bootstrap\RegisterProviders;
use System\Integrate\Exceptions\Handler;
use System\Integrate\Http\Middleware\MaintenanceMiddleware;
Expand All @@ -32,6 +33,7 @@ class Karnel
/** @var array<int, class-string> Apllication bootstrap register. */
protected array $bootstrappers = [
ConfigProviders::class,
RegisterFacades::class,
RegisterProviders::class,
BootProviders::class,
];
Expand Down
36 changes: 36 additions & 0 deletions tests/Integrate/Bootstrap/RegisterFacadesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace System\Integrate\Bootstrap;

use PHPUnit\Framework\TestCase;
use System\Collection\Collection;
use System\Integrate\Application;
use System\Support\Facades\Facade;

class RegisterFacadesTest extends TestCase
{
public function testBootstrap(): void
{
$app = new Application(dirname(__DIR__) . '/assets/app2/');
$app->set(Collection::class, fn () => new Collection(['php' => 'greate']));
$app->bootstrapWith([RegisterFacades::class]);

$this->assertTrue(TestCollectionFacade::has('php'));
}
}

/**
* @method static bool has(string $key)
*/
final class TestCollectionFacade extends Facade
{
/**
* {@inheritDoc}
*/
public static function getAccessor()
{
return Collection::class;
}
}

0 comments on commit 95238a6

Please sign in to comment.