}
$userAccount = $this->accountManager->getUser($targetUserObject);
+ $groups = $this->groupManager->getUserGroups($targetUserObject);
+ $gids = [];
+ foreach ($groups as $group) {
+ $gids[] = $group->getDisplayName();
+ }
// Find the data
$data['id'] = $targetUserObject->getUID();
$data['address'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_ADDRESS]['value'];
$data['webpage'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_WEBSITE]['value'];
$data['twitter'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_TWITTER]['value'];
+ $data['groups'] = $gids;
return $data;
}
}
public function testGetUserDataAsAdmin() {
+ $group = $this->getMockBuilder(IGroup::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
->method('isAdmin')
->with('admin')
->will($this->returnValue(true));
+ $this->groupManager
+ ->expects($this->any())
+ ->method('getUserGroups')
+ ->willReturn([$group, $group, $group]);
+ $group->expects($this->at(0))
+ ->method('getDisplayName')
+ ->willReturn('group0');
+ $group->expects($this->at(1))
+ ->method('getDisplayName')
+ ->willReturn('group1');
+ $group->expects($this->at(2))
+ ->method('getDisplayName')
+ ->willReturn('group2');
$this->accountManager->expects($this->any())->method('getUser')
->with($targetUser)
->willReturn(
'phone' => 'phone',
'address' => 'address',
'webpage' => 'website',
- 'twitter' => 'twitter'
+ 'twitter' => 'twitter',
+ 'groups' => ['group0', 'group1', 'group2']
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UserToGet']));
}
->method('isAdmin')
->with('subadmin')
->will($this->returnValue(false));
+ $this->groupManager
+ ->expects($this->any())
+ ->method('getUserGroups')
+ ->willReturn([]);
$subAdminManager = $this->getMockBuilder('OC\SubAdmin')
->disableOriginalConstructor()
->getMock();
'phone' => 'phone',
'address' => 'address',
'webpage' => 'website',
- 'twitter' => 'twitter'
+ 'twitter' => 'twitter',
+ 'groups' => []
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UserToGet']));
}
->expects($this->once())
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
+ $this->groupManager
+ ->expects($this->any())
+ ->method('getUserGroups')
+ ->willReturn([]);
$this->api
->expects($this->once())
->method('fillStorageInfo')
'phone' => 'phone',
'address' => 'address',
'webpage' => 'website',
- 'twitter' => 'twitter'
+ 'twitter' => 'twitter',
+ 'groups' => []
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['subadmin']));
}