process(new User('admin@ep-reisen.de', 'Admin')); self::assertSame('admin@ep-reisen.de', $record->extra['actor']); } /** * PHPUnit runs under the CLI SAPI, which is the same context a console command or the * message worker writes from -- so this is the system branch, not the anonymous one. */ public function testAWriteWithNoUserBehindItIsAttributedToTheSystem(): void { $record = $this->process(null); self::assertSame(AuditActorProcessor::SYSTEM, $record->extra['actor']); } private function process(?User $user): LogRecord { $security = $this->createStub(Security::class); $security->method('getUser')->willReturn($user); $processor = new AuditActorProcessor($security); return $processor(new LogRecord( new \DateTimeImmutable(), 'audit', Level::Info, 'Booking created.', )); } }