2 require_once('include/nusoap/nusoap.php');
3 require_once('modules/Users/User.php');
9 class Bug40250Test extends Sugar_PHPUnit_Framework_TestCase
12 public $_soapClient = null;
13 public $_session = null;
14 public $_sessionId = '';
19 public function setUp()
22 $this->_setupTestUser();
23 $this->_soapClient = new nusoapclient($GLOBALS['sugar_config']['site_url'].'/soap.php',false,false,false,false,false,60,60);
28 * Remove anything that was used during this test
31 public function tearDown() {
32 global $soap_version_test_accountId, $soap_version_test_opportunityId, $soap_version_test_contactId;
33 $this->_tearDownTestUser();
35 $this->_sessionId = '';
38 public function testRetrieveUsersList() {
39 //First retrieve the users count (should be at least 1)
40 $countArr = $this->_soapClient->call('get_entries_count',array('session'=>$this->_sessionId,'module_name'=>'Users','query'=>" users.status = 'active' ",0));
41 $count = $countArr['result_count'];
42 $this->assertTrue($count > 1, 'no users were retrieved so the test user was not set up correctly');
44 //now retrieve the list of users
45 $usersArr = $this->_soapClient->call('get_entry_list',array('session'=>$this->_sessionId,'module_name'=>'Users','query'=>" users.status = 'active' ", 'user_name','0' ,'select_field'=>array('user_name'),100,0));
46 $usersCount = $usersArr['result_count'];
48 //the count from both functions should be the same
49 $this->assertTrue($count == $usersCount ,'count is not the same which means that the 2 calls are generating different results.');
52 $result = $this->_soapClient->call('logout',array('session' => $this->_sessionId));
55 /**********************************
56 * HELPER PUBLIC FUNCTIONS
57 **********************************/
60 * Attempt to login to the soap server
62 * @return $set_entry_result - this should contain an id and error. The id corresponds
65 public function _login(){
67 $result = $this->_soapClient->call('login',
69 array('user_name' => $this->_user->user_name,
70 'password' => $this->_user->user_hash,
72 'application_name' => 'SoapTest')
74 $this->_sessionId = $result['id'];
83 public function _setupTestUser() {
84 $this->_user = SugarTestUserUtilities::createAnonymousUser();
85 $this->_user->status = 'Active';
86 $this->_user->is_admin = 1;
93 * Remove user created for test
96 public function _tearDownTestUser() {
97 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();