*/
public function setDisplayName($uid, $displayName) {
if ($this->userPluginManager->implementsActions(Backend::SET_DISPLAYNAME)) {
- return $this->userPluginManager->setDisplayName($uid, $displayName);
+ $this->userPluginManager->setDisplayName($uid, $displayName);
+ $this->access->cacheUserDisplayName($uid, $displayName);
+ return $displayName;
}
return false;
}
}
public function testSetDisplayNameWithPlugin() {
+ $newDisplayName = 'J. Baker';
$this->pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::SET_DISPLAYNAME)
->willReturn(true);
$this->pluginManager->expects($this->once())
->method('setDisplayName')
- ->with('uid','displayName')
- ->willReturn('result');
+ ->with('uid', $newDisplayName)
+ ->willReturn($newDisplayName);
+ $this->access->expects($this->once())
+ ->method('cacheUserDisplayName');
+
+ $this->assertEquals($newDisplayName, $this->backend->setDisplayName('uid', $newDisplayName));
+ }
+
+ /**
+ * @expectedException \OC\HintException
+ */
+ public function testSetDisplayNameErrorWithPlugin() {
+ $newDisplayName = 'J. Baker';
+ $this->pluginManager->expects($this->once())
+ ->method('implementsActions')
+ ->with(Backend::SET_DISPLAYNAME)
+ ->willReturn(true);
+ $this->pluginManager->expects($this->once())
+ ->method('setDisplayName')
+ ->with('uid', $newDisplayName)
+ ->willThrowException(new HintException('something happned'));
+ $this->access->expects($this->never())
+ ->method('cacheUserDisplayName');
- $this->assertEquals($this->backend->setDisplayName('uid', 'displayName'),'result');
+ $this->backend->setDisplayName('uid', $newDisplayName);
}
public function testSetDisplayNameFailing() {
->method('implementsActions')
->with(Backend::SET_DISPLAYNAME)
->willReturn(false);
+ $this->access->expects($this->never())
+ ->method('cacheUserDisplayName');
$this->assertFalse($this->backend->setDisplayName('uid', 'displayName'));
}