@@ -1391,23 +1391,47 @@ public function testCanChangeAvatarWithPlugin() {
13911391 }
13921392
13931393 public function testSetDisplayNameWithPlugin () {
1394+ $ newDisplayName = 'J. Baker ' ;
13941395 $ this ->pluginManager ->expects ($ this ->once ())
13951396 ->method ('implementsActions ' )
13961397 ->with (Backend::SET_DISPLAYNAME )
13971398 ->willReturn (true );
13981399 $ this ->pluginManager ->expects ($ this ->once ())
13991400 ->method ('setDisplayName ' )
1400- ->with ('uid ' ,'displayName ' )
1401- ->willReturn ('result ' );
1401+ ->with ('uid ' , $ newDisplayName )
1402+ ->willReturn ($ newDisplayName );
1403+ $ this ->access ->expects ($ this ->once ())
1404+ ->method ('cacheUserDisplayName ' );
1405+
1406+ $ this ->assertEquals ($ newDisplayName , $ this ->backend ->setDisplayName ('uid ' , $ newDisplayName ));
1407+ }
1408+
1409+ /**
1410+ * @expectedException \OC\HintException
1411+ */
1412+ public function testSetDisplayNameErrorWithPlugin () {
1413+ $ newDisplayName = 'J. Baker ' ;
1414+ $ this ->pluginManager ->expects ($ this ->once ())
1415+ ->method ('implementsActions ' )
1416+ ->with (Backend::SET_DISPLAYNAME )
1417+ ->willReturn (true );
1418+ $ this ->pluginManager ->expects ($ this ->once ())
1419+ ->method ('setDisplayName ' )
1420+ ->with ('uid ' , $ newDisplayName )
1421+ ->willThrowException (new HintException ('something happned ' ));
1422+ $ this ->access ->expects ($ this ->never ())
1423+ ->method ('cacheUserDisplayName ' );
14021424
1403- $ this ->assertEquals ( $ this -> backend ->setDisplayName ('uid ' , ' displayName ' ), ' result ' );
1425+ $ this ->backend ->setDisplayName ('uid ' , $ newDisplayName );
14041426 }
14051427
14061428 public function testSetDisplayNameFailing () {
14071429 $ this ->pluginManager ->expects ($ this ->once ())
14081430 ->method ('implementsActions ' )
14091431 ->with (Backend::SET_DISPLAYNAME )
14101432 ->willReturn (false );
1433+ $ this ->access ->expects ($ this ->never ())
1434+ ->method ('cacheUserDisplayName ' );
14111435
14121436 $ this ->assertFalse ($ this ->backend ->setDisplayName ('uid ' , 'displayName ' ));
14131437 }
0 commit comments