store = $this->createMock(TenantStore::class); $this->service = new TenantService($this->store); } public function testDepositRejectsTenantWithoutDomains(): void { $this->store->expects($this->never())->method('deposit'); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('at least one domain'); $this->service->deposit(new TenantObject()); } public function testDepositRejectsTenantWithEmptyDomainCollection(): void { $tenant = (new TenantObject())->setDomains(new DomainCollection([])); $this->store->expects($this->never())->method('deposit'); $this->expectException(\InvalidArgumentException::class); $this->service->deposit($tenant); } public function testDepositPassesTenantWithDomainsToStore(): void { $tenant = (new TenantObject()) ->setIdentifier('acme') ->setDomains(new DomainCollection(['acme.test'])); $this->store->expects($this->once())->method('deposit')->with($tenant)->willReturn($tenant); $this->assertSame($tenant, $this->service->deposit($tenant)); } public function testListDelegatesToStore(): void { $tenants = ['a' => new TenantObject()]; $this->store->expects($this->once())->method('list')->willReturn($tenants); $this->assertSame($tenants, $this->service->list()); } public function testDestroyDelegatesToStore(): void { $tenant = new TenantObject(); $this->store->expects($this->once())->method('destroy')->with($tenant); $this->service->destroy($tenant); } }