nexus-runtime-step
Deterministic runtime for testing — manual message stepping, virtual time, and guaranteed ordering.
What's in this package
StepRuntime— implementsRuntime; replaces the automatic tick loop withstep(),drain(), andadvanceTime()StepMailbox— always suspendsdequeueBlocking(), so each message requires an explicitstep()callVirtualClock— deterministic PSR-20 clock; starts at2026-01-01T00:00:00+00:00by default;advance(Duration)andset(DateTimeImmutable)move time forwardStepCancellable— boolean-flag cancellation handle
Install
composer require nexus-actors/runtime-step
Quick example
tests/Integration/CounterTest.php
use Monadial\Nexus\Core\Actor\ActorSystem;
use Monadial\Nexus\Core\Actor\Props;
use Monadial\Nexus\Runtime\Step\StepRuntime;
use Monadial\Nexus\Runtime\Step\VirtualClock;
use Monadial\Nexus\Runtime\Duration;
$clock = new VirtualClock();
$runtime = new StepRuntime($clock);
$system = ActorSystem::create('test', $runtime);
$ref = $system->spawn(Props::fromBehavior($counterBehavior), 'counter');
$ref->tell(new Increment());
$runtime->step(); // process exactly one message
$runtime->advanceTime(Duration::seconds(5)); // fire scheduled timers
self::assertSame(1, $captured);
drain() processes all pending messages in deterministic order. Use advanceTime() to fire scheduleOnce and scheduleRepeatedly callbacks without waiting for real wall time.
See also
- nexus-runtime —
Runtimeinterface and mailbox contracts - nexus-runtime-fiber — fiber runtime for development
Related pages