2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 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("service/v4_1/SugarWebServiceImplv4_1.php");
39 require_once('tests/service/SOAPTestCase.php');
40 require_once('soap/SoapError.php');
44 * get_entries_count doesn't work with custom fields
48 class Bug43339Test extends SOAPTestCase
51 private $_module = NULL;
52 private $_moduleName = 'Contacts';
53 private $_customFieldName = 'test_custom_c';
54 private $_field = null;
57 protected $session = array();
59 public function setUp()
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);
66 SugarTestHelper::setUp('beanList');
67 SugarTestHelper::setUp('beanFiles');
69 $_SERVER['REMOTE_ADDR'] = '0.0.0.0';
71 $this->_setupTestUser();
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;
97 $className = $beanList[$this->_moduleName];
98 require_once($beanFiles[$className]);
99 $this->_module = new $className();
101 $this->_df = new DynamicField($this->_moduleName);
103 $this->_df->setup($this->_module);
104 $this->_df->addFieldObject($this->_field);
108 * get_entries_count doesn't work with custom fields
112 public function testGetEntriesCountForCustomField()
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']);
119 $this->assertNotEquals(NULL, $assert['result_count']);
123 * Test for soap/SoapSugarUsers.php::get_entries_count()
127 public function testGetEntriesCountFromBasicSoap()
129 $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php';
132 $auth = $this->_soapClient->call('login',
135 'user_name' => $this->_user->user_name,
136 'password' => $this->_user->user_hash,
138 'application_name' => 'SoapTest', "name_value_list" => array()
143 'session' => $auth['id'],
144 'module_name' => $this->_moduleName,
145 'query' => $this->_customFieldName . ' LIKE \'\'',
148 $assert = $this->_soapClient->call('get_entries_count', $params);
150 $this->assertNotEquals(NULL, $assert['result_count']);
153 public function tearDown()
155 $this->_df->deleteField($this->_field);
157 SugarTestHelper::tearDown();
158 unset($_SERVER['REMOTE_ADDR']);
160 $this->_tearDownTestUser();
162 ini_set('session.use_cookies', $this->session['use_cookies']);
163 ini_set('session.cache_limiter', $this->session['cache_limiter']);