]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/soap/Bug43339Test.php
Release 6.5.1
[Github/sugarcrm.git] / tests / soap / Bug43339Test.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("service/v4_1/SugarWebServiceImplv4_1.php");
39 require_once('tests/service/SOAPTestCase.php');
40 require_once('soap/SoapError.php');
41
42 /**
43  * Bug #43339
44  * get_entries_count doesn't work with custom fields
45  *
46  * @ticket 43339
47  */
48 class Bug43339Test extends SOAPTestCase
49 {
50
51     private $_module = NULL;
52     private $_moduleName = 'Contacts';
53     private $_customFieldName = 'test_custom_c';
54     private $_field = null;
55     private $_df = null;
56
57     protected $session = array();
58
59     public function setUp()
60     {
61         $this->session['use_cookies'] = ini_get('session.use_cookies');
62         $this->session['cache_limiter'] = ini_get('session.session.cache_limiter');
63         ini_set('session.use_cookies', false);
64         ini_set('session.cache_limiter', false);
65
66         SugarTestHelper::setUp('beanList');
67         SugarTestHelper::setUp('beanFiles');
68
69         $_SERVER['REMOTE_ADDR'] = '0.0.0.0';
70
71         $this->_setupTestUser();
72
73         $this->_field = get_widget('varchar');
74         $this->_field->id = $this->_moduleName . $this->_customFieldName;
75         $this->_field->name = $this->_customFieldName;
76         $this->_field->vanme = 'LBL_' . strtoupper($this->_customFieldName);
77         $this->_field->comments = NULL;
78         $this->_field->help = NULL;
79         $this->_field->custom_module = $this->_moduleName;
80         $this->_field->type = 'varchar';
81         $this->_field->label = 'LBL_' . strtoupper($this->_customFieldName);
82         $this->_field->len = 255;
83         $this->_field->required = 0;
84         $this->_field->default_value = '';
85         $this->_field->date_modified = '2012-03-14 02:23:23';
86         $this->_field->deleted = 0;
87         $this->_field->audited = 0;
88         $this->_field->massupdate = 0;
89         $this->_field->duplicate_merge = 0;
90         $this->_field->reportable = 1;
91         $this->_field->importable = 'true';
92         $this->_field->ext1 = NULL;
93         $this->_field->ext2 = NULL;
94         $this->_field->ext3 = NULL;
95         $this->_field->ext4 = NULL;
96
97         $className = $beanList[$this->_moduleName];
98         require_once($beanFiles[$className]);
99         $this->_module = new $className();
100
101         $this->_df = new DynamicField($this->_moduleName);
102
103         $this->_df->setup($this->_module);
104         $this->_df->addFieldObject($this->_field);
105     }
106
107     /**
108      * get_entries_count doesn't work with custom fields
109      *
110      * @group 43339
111      */
112     public function testGetEntriesCountForCustomField()
113     {
114         $api = new SugarWebServiceImplv4_1();
115         $auth = $api->login(array('user_name' => self::$_user->user_name, 'password' => self::$_user->user_hash, 'version' => '.01'), 'SoapTest', array());
116         $assert = $api->get_entries_count($auth['id'], $this->_moduleName, $this->_customFieldName . ' LIKE \'\'', 0);
117         $api->logout($auth['id']);
118
119         $this->assertNotEquals(NULL, $assert['result_count']);
120     }
121
122     /**
123      * Test for soap/SoapSugarUsers.php::get_entries_count()
124      *
125      * @group 43339
126      */
127     public function testGetEntriesCountFromBasicSoap()
128     {
129         $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php';
130         parent::setUp();
131
132         $auth = $this->_soapClient->call('login',
133             array('user_auth' =>
134             array(
135                 'user_name' => $this->_user->user_name,
136                 'password' => $this->_user->user_hash,
137                 'version' => '.01'),
138                 'application_name' => 'SoapTest', "name_value_list" => array()
139             )
140         );
141
142         $params = array(
143             'session' => $auth['id'],
144             'module_name' => $this->_moduleName,
145             'query' => $this->_customFieldName . ' LIKE \'\'',
146             'deleted' => 0
147         );
148         $assert = $this->_soapClient->call('get_entries_count', $params);
149
150         $this->assertNotEquals(NULL, $assert['result_count']);
151     }
152
153     public function tearDown()
154     {
155         $this->_df->deleteField($this->_field);
156
157         SugarTestHelper::tearDown();
158         unset($_SERVER['REMOTE_ADDR']);
159
160         $this->_tearDownTestUser();
161
162         ini_set('session.use_cookies', $this->session['use_cookies']);
163         ini_set('session.cache_limiter', $this->session['cache_limiter']);
164     }
165 }