refactor: unified kernal logic clean up
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -65,6 +65,44 @@ final class KernelTest extends TestCase
|
||||
self::assertTrue($scope->terminated());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Runner returns execution results and terminates')]
|
||||
public function runs(): void
|
||||
{
|
||||
$processor = new RecordingProcessor();
|
||||
[$kernel] = $this->kernel($processor);
|
||||
|
||||
$result = $kernel->executionRunner()->execute(
|
||||
ExecutionDescriptor::cli(),
|
||||
static fn(): string => 'complete',
|
||||
);
|
||||
|
||||
self::assertSame('complete', $result);
|
||||
self::assertSame(1, $processor->processed);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Runner terminates before rethrowing execution failures')]
|
||||
public function rethrows(): void
|
||||
{
|
||||
[$kernel] = $this->kernel();
|
||||
|
||||
try {
|
||||
$kernel->executionRunner()->execute(
|
||||
ExecutionDescriptor::cli(),
|
||||
static fn() => throw new \RuntimeException('Execution failed.'),
|
||||
);
|
||||
self::fail('Expected execution to fail.');
|
||||
} catch (\RuntimeException $error) {
|
||||
self::assertSame('Execution failed.', $error->getMessage());
|
||||
}
|
||||
|
||||
$scope = $kernel->beginExecution(ExecutionDescriptor::cli());
|
||||
$kernel->terminateExecution($scope, ExecutionOutcome::success());
|
||||
|
||||
self::assertTrue($scope->terminated());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Only one execution scope can be active')]
|
||||
public function rejectsConcurrentScopes(): void
|
||||
|
||||
Reference in New Issue
Block a user