Skip to content

Commit

Permalink
Merge pull request #1137 from hydephp/add-booted-helper-to-the-kernel
Browse files Browse the repository at this point in the history
Add a isBooted method to the HydeKernel
  • Loading branch information
caendesilva committed Feb 27, 2023
2 parents 59e2123 + 281552f commit 50b9b3a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ trait BootsHydeKernel
/** @var array<callable> */
protected array $bootedCallbacks = [];

/**
* Determine if the Kernel has booted.
*/
public function isBooted(): bool
{
return $this->booted;
}

/**
* Boot the Hyde Kernel and run the Auto-Discovery Process.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/framework/src/Hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
* @method static void setSourceRoot(string $sourceRoot)
* @method static void shareViewData(HydePage $page)
* @method static array toArray()
* @method static bool isBooted()
* @method static void boot()
*
* @see \Hyde\Foundation\Concerns\ForwardsFilesystem
Expand Down
20 changes: 20 additions & 0 deletions packages/framework/tests/Feature/HydeKernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,26 @@ public function test_can_use_booting_callbacks_to_inject_custom_pages()
$this->assertSame($page, $kernel->pages()->getPage('foo'));
$this->assertEquals($page->getRoute(), $kernel->routes()->getRoute('foo'));
}

public function test_is_booted_returns_false_when_not_booted()
{
$kernel = new HydeKernel();
$this->assertFalse($kernel->isBooted());
}

public function test_is_booted_returns_true_when_booted()
{
$kernel = new HydeKernel();
$kernel->boot();
$this->assertTrue($kernel->isBooted());
}

public function test_is_booted_method_on_the_facade()
{
$this->assertFalse(Hyde::isBooted());
Hyde::kernel()->boot();
$this->assertTrue(Hyde::isBooted());
}
}

class CallableClass
Expand Down

0 comments on commit 50b9b3a

Please sign in to comment.