tenants = $this->createMock(TenantStore::class); $this->configuration = new SystemStoreConfigurationService($this->tenants); } #[Test] public function listsConfiguredLogicalStores(): void { $tenant = (new TenantObject())->setConfiguration( (new TenantConfiguration())->jsonDeserialize([ 'stores' => [ 'previews' => [ 'provider' => 'local', 'service' => 'default', 'namespace' => 'previews', ], ], ]), ); $this->tenants->expects(self::once())->method('fetch')->with('tenant-a')->willReturn($tenant); $stores = $this->configuration->list('tenant-a'); self::assertSame('local', $stores['previews']->provider); } #[Test] public function atomicallyStoresOneLogicalStoreReference(): void { $this->tenants->expects(self::once()) ->method('storeConfigurationStore') ->with('tenant-a', 'previews', [ 'provider' => 'local', 'service' => 'default', 'namespace' => 'previews', ]) ->willReturn(true); $reference = $this->configuration->set( 'tenant-a', 'previews', 'local', 'default', 'previews', ); self::assertSame('local', $reference->provider); } #[Test] public function reportsAMissingTenantDuringConfiguration(): void { $this->tenants->expects(self::once())->method('storeConfigurationStore')->willReturn(false); $this->expectException(SystemStoreException::class); $this->configuration->set('missing', 'previews', 'local', 'default', 'previews'); } #[Test] public function atomicallyRemovesOneLogicalStoreReference(): void { $this->tenants->expects(self::once()) ->method('removeConfigurationStore') ->with('tenant-a', 'previews') ->willReturn(true); self::assertTrue($this->configuration->remove('tenant-a', 'previews')); } #[Test] public function reportsAMissingTenantDuringRemoval(): void { $this->tenants->expects(self::once())->method('removeConfigurationStore')->willReturn(null); $this->expectException(SystemStoreException::class); $this->configuration->remove('missing', 'previews'); } #[Test] public function rejectsUnsafeStoreNamesBeforeBuildingMongoPaths(): void { $this->tenants->expects(self::never())->method('storeConfigurationStore'); $this->expectException(\InvalidArgumentException::class); $this->configuration->set('tenant-a', 'previews.other', 'local', 'default', 'previews'); } }