public function testLoginAsReturnsASoapFaultIfUserNotLoggedIn() { $admin_session_hash = 'admin_session_hash'; $user = new MockUser(); $user->setReturnValue('isLoggedIn', false); $um = new MockUserManager(); $um->setReturnValue('getCurrentUser', $user); $user_soap_server = new User_SOAPServer($um); $user_name = 'toto'; $this->expectException('SoapFault'); $um->expectNever('loginAs'); $user_soap_server->loginAs($admin_session_hash, $user_name); }
function testUserInSecondBranch() { $sync = new LDAP_DirectorySynchronizationTestVersion($this); $res = new MockLDAPResult($this); $res->setReturnValue('getLogin', 'mis_1234'); $lri = new MockLDAPResultIterator($this); $lri->setReturnValue('count', 1); $lri->setReturnValueAt(0, 'valid', true); $lri->setReturnValueAt(1, 'valid', false); $lri->setReturnReference('current', $res); $ldap = new MockInhLDAP($this); $ldap->setReturnValue('getErrno', LDAP::ERR_SUCCESS); $param1 = 'ou=People,dc=st,dc=com '; $param2 = ' ou=Intranet,dc=st,dc=com '; $ldap->setReturnValueAt(0, 'search', false); $ldap->setReturnValueAt(1, 'search', $lri); $ldap->setReturnValueAt(2, 'search', false); $ldap->expectCallCount('search', 2); $ldap->setReturnValue('getLDAPParam', 'ou=People,dc=st,dc=com ; ou=Intranet,dc=st,dc=com ; ou=Extranet,dc=st,dc=com'); $sync->__construct($ldap, mock('TruncateLevelLogger')); $um = new MockUserManager($this); $um->expectNever('updateDb'); $sync->setReturnValue('getUserManager', $um); $lum = new MockLDAP_UserManager($this); $lum->expectNever('updateLdapUid'); $sync->setReturnValue('getLdapUserManager', $lum); $lus = new MockLDAP_UserSync($this); $lus->setReturnValue('sync', false); $lus->expectOnce('sync'); $sync->setReturnValue('getLdapUserSync', $lus); $syncReminderManager = new MockLDAP_SyncReminderNotificationManager($this); $sync->setReturnValue('getLdapSyncReminderNotificationManager', $syncReminderManager); $row = array('user_id' => '4321', 'ldap_id' => 'ed1234', 'ldap_uid' => 'mis_1234'); $sync->ldapSync($row, 1); }
function testInternalCachingByUserName() { $dao = new MockUserDao($this); $dar = new MockDataAccessResult($this); $dao->setReturnReference('searchByUserName', $dar); $dar->setReturnValueAt(0, 'getRow', array('user_name' => 'user_name', 'realname' => 'realname', 'user_id' => 123)); $dar->setReturnValueAt(1, 'getRow', false); $dao->expectNever('searchByUserId', 'User should be cached'); $um = new MockUserManager(); $um->setReturnValue('isUserLoadedById', false, array(123)); $um->setReturnValue('isUserLoadedByUserName', false, array('user_name')); $um->expectNever('getUserById'); $um->expectNever('getUserByUserName'); $uh = new UserHelperTestVersion($this); $uh->setReturnValue('_getUserManager', $um); $uh->setReturnValue('_isUserNameNone', false); $uh->setReturnValue('_getCurrentUserUsernameDisplayPreference', 1); $uh->setReturnReference('_getUserDao', $dao); $uh->__construct(); $this->assertEqual("user_name (realname)", $uh->getDisplayNameFromUserName('user_name')); $this->assertEqual("user_name (realname)", $uh->getDisplayNameFromUserId(123)); }