Skip to content

PAM Native Testing

Terminal window
pam add testing
pam doctor
$native = NativeTestHarness::install();
$native->succeed('auth.session', 'current', [
'identifier' => 'user-1',
'state' => 2,
]);
// Exercise production code.
$native->assertCalled('auth.session', 'current');
$native->assertSatisfied();
NativeTestHarness::uninstall();

NativeTestHarness owns install/teardown; FakeNativeModuleTransport stubs success/failure, records calls, defers callbacks, and asserts completion; DispatchMode, RecordedModuleCall, and StubbedModuleResponse type fixtures.

Unstubbed calls fail immediately. Always call assertSatisfied() to catch unused responses and pending completions, flush deferred work, and uninstall in teardown even after failure so production transport cannot leak between tests.