dataStore = new DataStore($database); try { $this->dataStore->getDatabase()->drop(); $this->databaseAvailable = true; } catch (\MongoDB\Driver\Exception\Exception $error) { self::markTestSkipped('MongoDB is unavailable: '.$error->getMessage()); } } protected function tearDown(): void { if ($this->databaseAvailable) { $this->dataStore->getDatabase()->drop(); } } #[TestDox('Firewall settings updates persist without replacing unrelated tenant configuration')] public function testPersistence(): void { $tenants = new TenantService(new TenantStore($this->dataStore)); $tenants->deposit((new TenantObject()) ->setIdentifier('tenant-a') ->setEnabled(true) ->setLabel('Tenant A') ->setDomains(new DomainCollection(['tenant-a.example.test'])) ->setConfiguration((new TenantConfiguration())->jsonDeserialize([ 'security' => ['code' => 'keep-me'], ]))); $settings = new FirewallSettingsService( $tenants, $this->createStub(EventDispatcherInterface::class) ); $settings->update( 'tenant-a', false, 8, 600, 7200, 'Tighten authentication controls', 'admin-a' ); $stored = $tenants->fetchById('tenant-a')->getConfiguration(); self::assertFalse($stored->firewall()->enabled()); self::assertSame(8, $stored->firewall()->maxAuthFailures()); self::assertSame(600, $stored->firewall()->authFailureWindow()); self::assertSame(7200, $stored->firewall()->autoBlockDuration()); self::assertSame('keep-me', $stored->security()->code()); } }