config = $this->createMock(IConfig::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->accountManager = $this->createMock(IAccountManager::class);
$this->service = new DashboardService(
$this->config,
'alice',
$this->userManager,
$this->accountManager,
);
}
public function testGetBirthdate() {
$user = $this->createMock(IUser::class);
$this->userManager->method('get')
->willReturn($user);
$account = new Account($user);
$account->setProperty(
IAccountManager::PROPERTY_BIRTHDATE,
'2024-12-10T00:00:00.000Z',
IAccountManager::SCOPE_LOCAL,
IAccountManager::VERIFIED,
);
$this->accountManager->method('getAccount')
->willReturn($account);
$birthdate = $this->service->getBirthdate();
$this->assertEquals('2024-12-10T00:00:00.000Z', $birthdate);
}
public function testGetBirthdatePropertyDoesNotExist() {
$user = $this->createMock(IUser::class);
$this->userManager->method('get')
->willReturn($user);
$account = new Account($user);
$this->accountManager->method('getAccount')
->willReturn($account);
$birthdate = $this->service->getBirthdate();
$this->assertEquals('', $birthdate);
}
public function testGetBirthdateUserNotFound() {
$this->userManager->method('get')
->willReturn(null);
$birthdate = $this->service->getBirthdate();
$this->assertEquals('', $birthdate);
}
public function testGetBirthdateNoUserId() {
$service = new DashboardService(
$this->config,
null,
$this->userManager,
$this->accountManager,
);
$birthdate = $service->getBirthdate();
$this->assertEquals('', $birthdate);
}
}
ording-with-delete'>Jerome-Herbinet-replace-remove-wording-with-delete
Nextcloud server, a safe home for all your data: https://github.com/nextcloud/server | www-data |
blob: c3e83945e9a8bc873b90c7ae1895c98ee89d0a0a (
plain)