redactMetadata([ 'email' => 'john@example.com', 'token' => 'abc', 'active' => 1, 'nested' => ['password' => 'secret'], ]); $this->assertSame('[REDACTED]', $redacted['email']); $this->assertSame('[REDACTED]', $redacted['token']); $this->assertSame(1, $redacted['active']); $this->assertSame('[REDACTED]', $redacted['nested']['password']); } public function testBuildChangeSetUsesAllowlistAndRedactsOtherValues(): void { $service = new SystemAuditRedactionService(); $changeSet = $service->buildChangeSet( ['active' => 0, 'description' => 'old'], ['active' => 1, 'description' => 'new'] ); $this->assertSame(['active', 'description'], $changeSet['changed_fields']); $this->assertSame(0, $changeSet['changes']['active']['before']); $this->assertSame(1, $changeSet['changes']['active']['after']); $this->assertSame('[REDACTED]', $changeSet['changes']['description']['before']); $this->assertSame('[REDACTED]', $changeSet['changes']['description']['after']); } }