]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/service/Bug51617Test.php
Release 6.4.4
[Github/sugarcrm.git] / tests / service / Bug51617Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
5  * 
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.
12  * 
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
16  * details.
17  * 
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
21  * 02110-1301 USA.
22  * 
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.
25  * 
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.
29  * 
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  ********************************************************************************/
36
37
38 require_once 'tests/service/SOAPTestCase.php';
39
40 class Bug51617Test extends SOAPTestCase
41 {
42     protected $_account;
43
44     public function setUp()
45     {
46         $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/service/v2/soap.php';
47
48         $beanList = array();
49         $beanFiles = array();
50         require('include/modules.php');
51         $GLOBALS['beanList'] = $beanList;
52         $GLOBALS['beanFiles'] = $beanFiles;
53         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
54         $GLOBALS['current_user']->status = 'Active';
55         $GLOBALS['current_user']->is_admin = 1;
56         $GLOBALS['current_user']->save();
57
58         $this->field = get_widget('varchar');
59         $this->field->id = 'Accountstest_custom_c';
60         $this->field->name = 'test_custom_c';
61         $this->field->vanme = 'LBL_TEST_CUSTOM_C';
62         $this->field->comments = NULL;
63         $this->field->help = NULL;
64         $this->field->custom_module = 'Accounts';
65         $this->field->type = 'varchar';
66         $this->field->label = 'LBL_TEST_CUSTOM_C';
67         $this->field->len = 255;
68         $this->field->required = 0;
69         $this->field->default_value = NULL;
70         $this->field->date_modified = '2009-09-14 02:23:23';
71         $this->field->deleted = 0;
72         $this->field->audited = 0;
73         $this->field->massupdate = 0;
74         $this->field->duplicate_merge = 0;
75         $this->field->reportable = 1;
76         $this->field->importable = 'true';
77         $this->field->ext1 = NULL;
78         $this->field->ext2 = NULL;
79         $this->field->ext3 = NULL;
80         $this->field->ext4 = NULL;
81
82         $this->df = new DynamicField('Accounts');
83         $this->mod = new Account();
84         $this->df->setup($this->mod);
85         $this->df->addFieldObject($this->field);
86         $this->df->buildCache('Accounts');
87         VardefManager::clearVardef();
88         VardefManager::refreshVardefs('Accounts', 'Account');
89         $this->mod->field_defs = $GLOBALS['dictionary']['Account']['fields'];
90
91         $this->_account = SugarTestAccountUtilities::createAccount();
92
93         $this->_account->test_custom_c = 'Custom Field';
94         $this->_account->save();
95
96         $GLOBALS['db']->commit(); // Making sure we commit any changes
97
98         parent::setUp();
99     }
100
101     public function tearDown()
102     {
103         $this->df->deleteField($this->field);
104
105         SugarTestAccountUtilities::removeAllCreatedAccounts();
106
107         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
108         unset($GLOBALS['current_user']);
109
110         parent::tearDown();
111
112         global $soap_version_test_accountId, $soap_version_test_opportunityId, $soap_version_test_contactId;
113         unset($soap_version_test_accountId);
114         unset($soap_version_test_opportunityId);
115         unset($soap_version_test_contactId);
116         unset($GLOBALS['beanFiles']);
117         unset($GLOBALS['beanList']);
118     }
119
120     public function testGetEntryListWithCustomField()
121     {
122         $this->_login();
123         $result = $this->_soapClient->call('get_entry_list',
124             array(
125                  'session'=>$this->_sessionId,
126                  "module_name" => 'Accounts',
127                  '',
128                  '',
129                  0,
130                  "select_fields" => array('id', 'name', 'test_custom_c'),
131                  null,
132                  'max_results' => 1
133             )
134         );
135
136         $this->assertTrue($result['result_count'] > 0,
137             'Get_entry_list failed: Fault code: '.$this->_soapClient->faultcode.', fault string:'.$this->_soapClient->faultstring.', fault detail: '.$this->_soapClient->faultdetail);
138
139         $row = array();
140         $row = $result['entry_list'][0]['name_value_list'];
141
142         // find the custom field
143         if (!empty($row))
144         {
145             foreach($row as $r) {
146                 // just make sure they are all not empty
147                 $this->assertNotEmpty($r['value']);
148                 // make sure that the test field has our value in it
149                 if($r['name'] == "test_custom_c") {
150                     $this->assertEquals("Custom Field", $r['value']);
151                 }
152             }
153         } // if
154
155     } // fn
156 }