2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
38 require_once('include/nusoap/nusoap.php');
39 require_once('modules/Cases/Case.php');
40 require_once('modules/Accounts/Account.php');
46 class Bug39855Test extends Sugar_PHPUnit_Framework_TestCase
49 public $_case1 = null;
50 public $_case2 = null;
52 public $_soapClient = null;
53 public $_session = null;
54 public $_sessionId = '';
59 public function setUp()
62 $this->markTestSkipped('Skipping for now while investigating');
63 //setup test portal user
64 $this->_setupTestUser();
65 $this->_soapClient = new nusoapclient($GLOBALS['sugar_config']['site_url'].'/soap.php',false,false,false,false,false,600,600);
69 $account = new Account();
70 $account->name = 'test account for bug 39855';
71 $account->assigned_user_id = 'SugarUser';
73 $this->_acc = $account;
77 $case1->name = 'test case for bug 39855 ASDF';
78 $case1->account_id = $this->_acc->id;
79 $case1->status = 'New';
81 $this->_case1 = $case1;
84 //$account->id = 'a_'.$unid;
85 $case2->name = 'test case for bug 39855 QWER';
86 $case2->account_id = $this->_acc->id;
87 $case2->status = 'Rejected';
89 $this->_case2 = $case2;
95 * Remove anything that was used during this test
98 public function tearDown() {
99 global $soap_version_test_accountId, $soap_version_test_opportunityId, $soap_version_test_contactId;
100 $this->_tearDownTestUser();
102 $this->_sessionId = '';
103 $GLOBALS['db']->query("DELETE FROM cases WHERE name like 'test case for bug 39855%'");
104 $GLOBALS['db']->query("DELETE FROM accounts WHERE name like 'test account for bug 39855%'");
106 unset($this->_case1);
107 unset($this->_case2);
112 public function testGetEntry() {
113 //test retrieving a case by id
114 $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')));
115 $this->assertTrue($result['entry_list'][0]['id'] == $this->_case1->id,'portal_get_entry was not able to retrieve a case record by id');
117 $result = $this->_soapClient->call('portal_logout',array('session' => $this->_sessionId));
120 public function testGetEntryList() {
121 $w = " name LIKE 'test case for bug 39855 %' ";
123 $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')));
124 $this->assertTrue($result['result_count'] > 1,'portal_get_entry_list was not able to retrieve both cases using the following where clause: '.$w);
128 /**********************************
129 * HELPER PUBLIC FUNCTIONS
130 **********************************/
133 * Attempt to login to the soap server
135 * @return $set_entry_result - this should contain an id and error. The id corresponds
138 public function _login(){
139 global $current_user;
140 $result = $this->_soapClient->call('portal_login',
142 array('user_name' => $this->_user->user_name,
143 'password' => $this->_user->user_hash,
145 'user_name' =>'portal',
146 'application_name' => 'SoapTestPortal')
148 $this->_sessionId = $result['id'];
154 * Create a test portal user
157 public function _setupTestUser() {
158 $this->_user = SugarTestUserUtilities::createAnonymousUser();
159 $this->_user->status = 'Active';
160 $this->_user->portal_only = 1;
161 $this->_user->save();
167 * Remove user created for test
170 public function _tearDownTestUser() {
171 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();