feat: M3 import & indexing engine delivery layer with durable collision handling, space checking and console
This commit is contained in:
1 parent
93d991703c
commit
9d277d9e72
48 files changed
+5147
-4
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MeshVault\Tests\Unit\Console;
|
||||
|
||||
use MeshVault\Console\ConsoleServices;
|
||||
use MeshVault\Console\LazyConsoleServices;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
final class ConsoleServicesWiringTest extends TestCase
|
||||
{
|
||||
public function testLazyServicesDoNotBuildTheEngineUntilUsed(): void
|
||||
{
|
||||
$built = 0;
|
||||
$services = new LazyConsoleServices(function () use (&$built): ConsoleServices {
|
||||
$built++;
|
||||
return new FakeConsoleServices(importResult: 9);
|
||||
});
|
||||
|
||||
self::assertSame(0, $built, 'Construction alone must not touch configuration.');
|
||||
self::assertSame(9, $services->import('/srv/in', ['stl']));
|
||||
self::assertSame(1, $built);
|
||||
}
|
||||
|
||||
public function testLazyServicesBuildTheEngineOnlyOnce(): void
|
||||
{
|
||||
$built = 0;
|
||||
$delegate = new FakeConsoleServices(jobs: [1, 2]);
|
||||
$services = new LazyConsoleServices(function () use (&$built, $delegate): ConsoleServices {
|
||||
$built++;
|
||||
return $delegate;
|
||||
});
|
||||
|
||||
$services->runWorkerOnce(static fn (): bool => false);
|
||||
$services->runWorkerOnce(static fn (): bool => false);
|
||||
|
||||
self::assertSame(1, $built);
|
||||
self::assertSame(2, $delegate->runs);
|
||||
}
|
||||
|
||||
public function testLazyServicesPropagateConstructionFailures(): void
|
||||
{
|
||||
$services = new LazyConsoleServices(static function (): ConsoleServices {
|
||||
throw new RuntimeException('bad configuration');
|
||||
});
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$services->runWorkerOnce(static fn (): bool => false);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user