Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/foundation/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ class Application extends Container implements ApplicationContract, CachesConfig
*/
public const VERSION = '0.4';

/**
* The default bootstrap sequence for the application.
*
* Shared by the HTTP and console kernels and by the testing
* infrastructure so the boot paths cannot drift apart.
*
* @var array<int, class-string>
*/
public const DEFAULT_BOOTSTRAPPERS = [
\Hypervel\Foundation\Bootstrap\LoadEnvironmentVariables::class,
\Hypervel\Foundation\Bootstrap\LoadConfiguration::class,
\Hypervel\Foundation\Bootstrap\HandleExceptions::class,
\Hypervel\Foundation\Bootstrap\RegisterFacades::class,
\Hypervel\Foundation\Bootstrap\RegisterProviders::class,
\Hypervel\Di\Bootstrap\GenerateProxies::class,
\Hypervel\Foundation\Bootstrap\BootProviders::class,
];

/**
* The base path for the Hypervel installation.
*/
Expand Down
10 changes: 1 addition & 9 deletions src/foundation/src/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,7 @@ class Kernel implements KernelContract
/**
* The console application bootstrappers.
*/
protected array $bootstrappers = [
\Hypervel\Foundation\Bootstrap\LoadEnvironmentVariables::class,
\Hypervel\Foundation\Bootstrap\LoadConfiguration::class,
\Hypervel\Foundation\Bootstrap\HandleExceptions::class,
\Hypervel\Foundation\Bootstrap\RegisterFacades::class,
\Hypervel\Foundation\Bootstrap\RegisterProviders::class,
\Hypervel\Di\Bootstrap\GenerateProxies::class,
\Hypervel\Foundation\Bootstrap\BootProviders::class,
];
protected array $bootstrappers = \Hypervel\Foundation\Application::DEFAULT_BOOTSTRAPPERS;

public function __construct(
protected ContainerContract $app,
Expand Down
10 changes: 1 addition & 9 deletions src/foundation/src/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@ class Kernel implements KernelContract
*
* @var string[]
*/
protected array $bootstrappers = [
\Hypervel\Foundation\Bootstrap\LoadEnvironmentVariables::class,
\Hypervel\Foundation\Bootstrap\LoadConfiguration::class,
\Hypervel\Foundation\Bootstrap\HandleExceptions::class,
\Hypervel\Foundation\Bootstrap\RegisterFacades::class,
\Hypervel\Foundation\Bootstrap\RegisterProviders::class,
\Hypervel\Di\Bootstrap\GenerateProxies::class,
\Hypervel\Foundation\Bootstrap\BootProviders::class,
];
protected array $bootstrappers = \Hypervel\Foundation\Application::DEFAULT_BOOTSTRAPPERS;

/**
* The application's middleware stack.
Expand Down
12 changes: 12 additions & 0 deletions src/foundation/src/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ protected function setUp(): void
protected function refreshApplication(): void
{
$this->app = $this->createApplication();

// Bootstrap the freshly-created app for the test context. Without this the
// bootstrappers (RegisterFacades, RegisterProviders, BootProviders, …) never
// run in tests — only on the HTTP/console boot path — so the facade root is
// never bound and the very next facade call in setUp fails. HandleExceptions is
// deliberately omitted so PHPUnit (not the app's Swoole error handler) reports failures.
if (! $this->app->hasBeenBootstrapped()) {
$this->app->bootstrapWith(array_values(array_diff(
Application::DEFAULT_BOOTSTRAPPERS,
[\Hypervel\Foundation\Bootstrap\HandleExceptions::class],
)));
}
}

/**
Expand Down