refactor(kernel): unify HTTP and CLI application lifecycle
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KTXT\Unit\Application;
|
||||
|
||||
use KTXC\Application\KernelOptions;
|
||||
use KTXC\Application\ProjectPaths;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\Attributes\TestDox;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class ProjectPathsTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
#[TestDox('Project roots resolve identically from nested entrypoints')]
|
||||
public function resolves(): void
|
||||
{
|
||||
$root = dirname(__DIR__, 4);
|
||||
$fromRoot = ProjectPaths::resolve($root);
|
||||
$fromCore = ProjectPaths::resolve($root . '/core/lib/index.php');
|
||||
$fromConsole = ProjectPaths::resolve($root . '/bin/console');
|
||||
|
||||
self::assertSame($fromRoot->project, $fromCore->project);
|
||||
self::assertSame($fromRoot->project, $fromConsole->project);
|
||||
self::assertSame($fromRoot->modules(), $fromCore->modules());
|
||||
self::assertSame($fromRoot->logs(), $fromConsole->logs());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Missing project roots are rejected')]
|
||||
public function rejectsMissingRoots(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
ProjectPaths::resolve(sys_get_temp_dir());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Empty kernel environments are rejected')]
|
||||
public function rejectsEmptyEnvironments(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new KernelOptions(ProjectPaths::resolve(dirname(__DIR__, 4)), '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user