appConfig = $this->createMock(IAppConfig::class); $this->userManager = $this->createMock(IUserManager::class); $this->l10n = $this->createMock(IL10N::class); $this->l10n->method('t')->willReturnCallback(fn ($text, $parameters = []) => vsprintf($text, $parameters)); } public function testSystemAddressBookDisabled() { $this->appConfig->method('getValueBool') ->with(Application::APP_ID, 'system_addressbook_exposed', true) ->willReturn(false); $check = new SystemAddressBookSize($this->appConfig, $this->userManager, $this->l10n); $result = $check->run(); $this->assertEquals('success', $result->getSeverity()); $this->assertStringContainsString('disabled', $result->getDescription()); } public function testSystemAddressBookOverLimit() { $this->appConfig->method('getValueBool') ->willReturn(true); $this->userManager->method('countSeenUsers') ->willReturn(6000); $this->appConfig->method('getValueInt') ->willReturn(5000); $check = new SystemAddressBookSize($this->appConfig, $this->userManager, $this->l10n); $result = $check->run(); $this->assertEquals('warning', $result->getSeverity()); $this->assertStringContainsString('more than the configured limit', $result->getDescription()); } public function testSystemAddressBookUnderLimit() { $this->appConfig->method('getValueBool') ->willReturn(true); $this->userManager->method('countSeenUsers') ->willReturn(1000); $this->appConfig->method('getValueInt') ->willReturn(5000); $check = new SystemAddressBookSize($this->appConfig, $this->userManager, $this->l10n); $result = $check->run(); $this->assertEquals('success', $result->getSeverity()); $this->assertStringContainsString('less than the configured limit', $result->getDescription()); } }