2 require_once('include/nusoap/nusoap.php');
3 require_once('modules/Cases/Case.php');
4 require_once('modules/Accounts/Account.php');
10 class Bug39855Test extends Sugar_PHPUnit_Framework_TestCase
13 public $_case1 = null;
14 public $_case2 = null;
16 public $_soapClient = null;
17 public $_session = null;
18 public $_sessionId = '';
23 public function setUp()
26 $this->markTestSkipped('Skipping for now while investigating');
27 //setup test portal user
28 $this->_setupTestUser();
29 $this->_soapClient = new nusoapclient($GLOBALS['sugar_config']['site_url'].'/soap.php',false,false,false,false,false,600,600);
33 $account = new Account();
34 $account->name = 'test account for bug 39855';
35 $account->assigned_user_id = 'SugarUser';
37 $this->_acc = $account;
41 $case1->name = 'test case for bug 39855 ASDF';
42 $case1->account_id = $this->_acc->id;
43 $case1->status = 'New';
45 $this->_case1 = $case1;
48 //$account->id = 'a_'.$unid;
49 $case2->name = 'test case for bug 39855 QWER';
50 $case2->account_id = $this->_acc->id;
51 $case2->status = 'Rejected';
53 $this->_case2 = $case2;
59 * Remove anything that was used during this test
62 public function tearDown() {
63 global $soap_version_test_accountId, $soap_version_test_opportunityId, $soap_version_test_contactId;
64 $this->_tearDownTestUser();
66 $this->_sessionId = '';
67 $GLOBALS['db']->query("DELETE FROM cases WHERE name like 'test case for bug 39855%'");
68 $GLOBALS['db']->query("DELETE FROM accounts WHERE name like 'test account for bug 39855%'");
76 public function testGetEntry() {
77 //test retrieving a case by id
78 $result = $this->_soapClient->call('portal_get_entry',array('session'=>$this->_sessionId,'module_name'=>'Cases','id'=>$this->_case1->id ,'select_field'=>array('case_number','status', 'name','description')));
79 $this->assertTrue($result['entry_list'][0]['id'] == $this->_case1->id,'portal_get_entry was not able to retrieve a case record by id');
81 $result = $this->_soapClient->call('portal_logout',array('session' => $this->_sessionId));
84 public function testGetEntryList() {
85 $w = " name LIKE 'test case for bug 39855 %' ";
87 $result = $this->_soapClient->call('portal_get_entry_list',array('session'=>$this->_sessionId,'module_name'=>'Cases','where'=>$w ,'', 'select_field'=>array('case_number','status', 'name','description')));
88 $this->assertTrue($result['result_count'] > 1,'portal_get_entry_list was not able to retrieve both cases using the following where clause: '.$w);
92 /**********************************
93 * HELPER PUBLIC FUNCTIONS
94 **********************************/
97 * Attempt to login to the soap server
99 * @return $set_entry_result - this should contain an id and error. The id corresponds
102 public function _login(){
103 global $current_user;
104 $result = $this->_soapClient->call('portal_login',
106 array('user_name' => $this->_user->user_name,
107 'password' => $this->_user->user_hash,
109 'user_name' =>'portal',
110 'application_name' => 'SoapTestPortal')
112 $this->_sessionId = $result['id'];
118 * Create a test portal user
121 public function _setupTestUser() {
122 $this->_user = SugarTestUserUtilities::createAnonymousUser();
123 $this->_user->status = 'Active';
124 $this->_user->portal_only = 1;
125 $this->_user->save();
131 * Remove user created for test
134 public function _tearDownTestUser() {
135 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();