> */ private array $capturedLogs = []; public function test_change_ip_vm_linux_never_logs_the_guest_password(): void { $this->interceptLogs(); (new PowerShellService(new Client()))->changeIpVM( vmName: 'vm-test', vmwareId: 'vm-3340', ipAddress: '10.0.0.5', gateway: '10.0.0.1', osType: 'linux', guestUser: 'root', guestPassword: self::SECRET, ); $this->assertLogsNeverContainSecret(); } public function test_change_ip_vm_windows_never_logs_the_guest_password(): void { $this->interceptLogs(); (new PowerShellService(new Client()))->changeIpVM( vmName: 'vm-test', vmwareId: 'vm-3340', ipAddress: '10.0.0.5', gateway: '10.0.0.1', osType: 'windows', guestUser: 'administrator', guestPassword: self::SECRET, ); $this->assertLogsNeverContainSecret(); } private function interceptLogs(): void { $collect = function (...$args): void { $this->capturedLogs[] = $args; }; Log::shouldReceive('channel')->andReturnSelf(); Log::shouldReceive('info')->andReturnUsing($collect); Log::shouldReceive('warning')->andReturnUsing($collect); Log::shouldReceive('error')->andReturnUsing($collect); } private function assertLogsNeverContainSecret(): void { $this->assertNotEmpty($this->capturedLogs, 'Expected at least one log call to have been made.'); foreach ($this->capturedLogs as $call) { $this->assertStringNotContainsString(self::SECRET, (string) json_encode($call)); } } }