1, 'name' => 'Acme Corp', 'uuid' => 'abc-123']; $repo = $this->createMock(TenantRepositoryInterface::class); $repo->expects($this->once()) ->method('find') ->with(1) ->willReturn($tenant); $gateway = new AuthTenantGateway($repo); $this->assertSame($tenant, $gateway->findById(1)); } public function testFindByIdReturnsNullWhenNotFound(): void { $repo = $this->createMock(TenantRepositoryInterface::class); $repo->expects($this->once()) ->method('find') ->with(999) ->willReturn(null); $gateway = new AuthTenantGateway($repo); $this->assertNull($gateway->findById(999)); } public function testFindByUuidDelegatesToRepository(): void { $tenant = ['id' => 5, 'name' => 'Beta Inc', 'uuid' => 'def-456']; $repo = $this->createMock(TenantRepositoryInterface::class); $repo->expects($this->once()) ->method('findByUuid') ->with('def-456') ->willReturn($tenant); $gateway = new AuthTenantGateway($repo); $this->assertSame($tenant, $gateway->findByUuid('def-456')); } public function testListDelegatesToRepository(): void { $tenants = [ ['id' => 1, 'name' => 'Acme Corp'], ['id' => 2, 'name' => 'Beta Inc'], ]; $repo = $this->createMock(TenantRepositoryInterface::class); $repo->expects($this->once()) ->method('list') ->willReturn($tenants); $gateway = new AuthTenantGateway($repo); $this->assertSame($tenants, $gateway->list()); } }