use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Mail\IMailer;
+use OCP\IAvatarManager;
/**
* @package OC\Settings\Controller
private $isEncryptionAppEnabled;
/** @var bool contains the state of the admin recovery setting */
private $isRestoreEnabled = false;
+ /** @var IAvatarManager */
+ private $avatarManager;
/**
* @param string $appName
IMailer $mailer,
$fromMailAddress,
IURLGenerator $urlGenerator,
- IAppManager $appManager) {
+ IAppManager $appManager,
+ IAvatarManager $avatarManager) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->mailer = $mailer;
$this->fromMailAddress = $fromMailAddress;
$this->urlGenerator = $urlGenerator;
+ $this->avatarManager = $avatarManager;
// check for encryption state - TODO see formatUserForIndex
$this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption');
if (is_null($displayName)) {
$displayName = '';
}
+
+ $avatarAvailable = false;
+ if ($this->config->getSystemValue('enable_avatars', true) === true) {
+ $avatarAvailable = $this->avatarManager->getAvatar($user->getUID())->exists();
+ }
+
return [
'name' => $user->getUID(),
'displayname' => $user->getDisplayName(),
'backend' => $user->getBackendClassName(),
'email' => $displayName,
'isRestoreDisabled' => !$restorePossible,
+ 'isAvatarAvailable' => $avatarAvailable,
];
}
->disableOriginalConstructor()->getMock();
$this->container['OCP\\App\\IAppManager'] = $this->getMockBuilder('OCP\\App\\IAppManager')
->disableOriginalConstructor()->getMock();
+
+
+ /*
+ * Set default avtar behaviour for whole testsuite
+ */
+ $this->container['OCP\\IAvatarManager'] = $this->getMock('OCP\IAvatarManager');
+
+ $avatarExists = $this->getMock('OCP\IAvatar');
+ $avatarExists->method('exists')->willReturn(true);
+ $avatarNotExists = $this->getMock('OCP\IAvatar');
+ $avatarNotExists->method('exists')->willReturn(false);
+ $this->container['OCP\\IAvatarManager']
+ ->method('getAvatar')
+ ->will($this->returnValueMap([
+ ['foo', $avatarExists],
+ ['bar', $avatarExists],
+ ['admin', $avatarNotExists],
+ ]));
+
+ $this->container['Config']
+ ->method('getSystemValue')
+ ->with('enable_avatars', true)
+ ->willReturn(true);
+
}
public function testIndexAdmin() {
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$foo
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('admin'));
$admin
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('bar'));
$bar
->method('getSubAdmin')
->will($this->returnValue($subadmin));
-
$expectedResponse = new DataResponse(
array(
0 => array(
'backend' => 'OC_User_Database',
'email' => 'foo@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
1 => array(
'name' => 'admin',
'backend' => '\Test\Util\User\Dummy',
'email' => 'admin@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => false,
),
2 => array(
'name' => 'bar',
'backend' => '\Test\Util\User\Dummy',
'email' => 'bar@dummy.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
)
);
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$foo
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('admin'));
$admin
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('bar'));
$bar
'backend' => '\Test\Util\User\Dummy',
'email' => 'bar@dummy.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
],
1=> [
'name' => 'foo',
'backend' => 'OC_User_Database',
'email' => 'foo@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
],
2 => [
'name' => 'admin',
'backend' => '\Test\Util\User\Dummy',
'email' => 'admin@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => false,
],
]
);
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$foo
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('admin'));
$admin
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('bar'));
$bar
'backend' => 'OC_User_Database',
'email' => 'foo@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
1 => array(
'name' => 'admin',
'backend' => '\Test\Util\User\Dummy',
'email' => 'admin@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => false,
),
2 => array(
'name' => 'bar',
'backend' => '\Test\Util\User\Dummy',
'email' => 'bar@dummy.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
)
);
$user = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$user
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$user
'backend' => 'OC_User_Database',
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
)
)
);
'subadmin' => array(),
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
'subadmin' => [],
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
'subadmin' => array(),
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
'subadmin' => [],
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
'backend' => $backend,
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
];
return [$user, $result];