/** * testUserUpdate * * @param Object $localobject User * @return void * @depends testUserFetch * The depends says test is run only if previous is ok */ public function testUserUpdate($localobject) { global $conf, $user, $langs, $db; $conf = $this->savconf; $user = $this->savuser; $langs = $this->savlangs; $db = $this->savdb; $this->changeProperties($localobject); $result = $localobject->update($user); print __METHOD__ . " id=" . $localobject->id . " result=" . $result . "\n"; $this->assertLessThan($result, 0); // Test everything are still same than specimen $newlocalobject = new User($this->savdb); $newlocalobject->initAsSpecimen(); $this->changeProperties($newlocalobject); $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id', 'socid', 'societe_id', 'ref', 'pass_indatabase', 'pass_indatabase_crypted', 'datec', 'datem', 'datelastlogin', 'datepreviouslogin')), array()); // Actual, Expected return $localobject; }
/** * testUserCreate * * @return void */ public function testUserCreate() { global $conf,$user,$langs,$db; $conf=$this->savconf; $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; $localobject=new User($this->savdb); $localobject->initAsSpecimen(); $result=$localobject->create($user); $this->assertLessThan($result, 0); print __METHOD__." result=".$result."\n"; return $result; }
$butlabel=$langs->trans("LDAPTestSynchroUser"); $testlabel='testuser'; $key=$conf->global->LDAP_KEY_USERS; $dn=$conf->global->LDAP_USER_DN; $objectclass=$conf->global->LDAP_USER_OBJECT_CLASS; show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass); } if (function_exists("ldap_connect")) { if ($_GET["action"] == 'testuser') { // Creation objet $object=new User($db); $object->initAsSpecimen(); // TODO Mutualize code following with other ldap_xxxx.php pages // Test synchro $ldap=new Ldap(); $result=$ldap->connect_bind(); if ($result > 0) { $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info); $result1=$ldap->delete($dn); // To be sure to delete existing records $result2=$ldap->add($dn,$info,$user); // Now the test $result3=$ldap->delete($dn); // Clean what we did