]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/soap/Bug63559Test.php
Release 6.5.15
[Github/sugarcrm.git] / tests / soap / Bug63559Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2013 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 /**
39  * Bug #63559
40  * Check if SOAP Sync from Outlook for Calls/Meetings
41  * returns proper IDs whether we use outlook_id for sync,
42  * or by matching given fields
43  *
44  * @author avucinic@sugarcrm.com
45  * @ticket 63559
46  */
47 class Bug63559Test extends Sugar_PHPUnit_Framework_TestCase
48 {
49     public function setUp()
50     {
51         SugarTestHelper::setUp('beanList');
52         SugarTestHelper::setUp('beanFiles');
53         SugarTestHelper::setUp('current_user');
54     }
55
56     public function tearDown()
57     {
58         SugarTestMeetingUtilities::removeAllCreatedMeetings();
59
60         SugarTestHelper::tearDown();
61     }
62
63     /**
64      * Test if set_entries returns proper IDs for Calls/Meetings
65      * with set outlook_id or with equal fields
66      *
67      * @param $module - Module name
68      * @param $outlookID - Outlook ID (must always be set, for the OPI Sync check to be initiated)
69      * @param $nameValueLists - name-value lists for set_entries call
70      *
71      * @dataProvider dataProvider
72      * @group 63559
73      */
74     public function testSetEntriesOPISync($module, $outlookID, $nameValueLists)
75     {
76         $meeting = SugarTestMeetingUtilities::createMeeting();
77         // Set the fields using $nameValueLists, and resave the meeting
78         foreach ($nameValueLists[0] as $nameValue) {
79             $meeting->$nameValue['name'] = $nameValue['value'];
80         }
81         $meeting->outlook_id = $outlookID;
82         $meeting->save();
83
84         // Mock $server and $server->wsdl
85         $server = $this->getMock('soap_server', array('register'));
86         $server->wsdl = $this->getMock('wsdl', array('addComplexType'));
87         // Need name space to be set
88         $NAMESPACE = '';
89         require_once('soap/SoapSugarUsers.php');
90         require_once('soap/SoapError.php');
91         // Unset $NAMESPACE, it was only needed in SoapSugarUsers.php
92         unset($NAMESPACE);
93
94         $actual = handle_set_entries($module, $nameValueLists);
95
96         $this->assertEquals($meeting->id, $actual['ids'][0], 'Meeting not synced properly.');
97     }
98
99     public static function dataProvider()
100     {
101         return array(
102             // Test case that will be synced by outlook_id
103             array(
104                 'Meetings', 'outlook_id_test_same',
105                 array(
106                     0 => array(
107                         array(
108                             'name' => 'outlook_id',
109                             'value' => 'outlook_id_test_same',
110                         ),
111                         array(
112                             'name' => 'name',
113                             'value' => 'OPI Test',
114                         ),
115                         array (
116                             'name' => 'date_start',
117                             'value' => '2013-05-05 21:00:00',
118                         ),
119                         array (
120                             'name' => 'date_end',
121                             'value' => '2013-05-05',
122                         ),
123                         array (
124                             'name' => 'duration_hours',
125                             'value' => '0',
126                         ),
127                         array (
128                             'name' => 'duration_minutes',
129                             'value' => '30',
130                         ),
131                         array (
132                             'name' => 'status',
133                             'value' => 'Held',
134                         ),
135                     ),
136                 )
137             ),
138             // Test case that will compare fields for sync
139             array(
140                 'Meetings', 'outlook_id_test_different',
141                 array(
142                     0 => array(
143                         array(
144                             'name' => 'outlook_id',
145                             'value' => 'outlook_id_test',
146                         ),
147                         array(
148                             'name' => 'name',
149                             'value' => 'OPI Test',
150                         ),
151                         array (
152                             'name' => 'date_start',
153                             'value' => '2013-05-05 21:00:00',
154                         ),
155                         array (
156                             'name' => 'date_end',
157                             'value' => '2013-05-05',
158                         ),
159                         array (
160                             'name' => 'duration_hours',
161                             'value' => '0',
162                         ),
163                         array (
164                             'name' => 'duration_minutes',
165                             'value' => '30',
166                         ),
167                         array (
168                             'name' => 'status',
169                             'value' => 'Held',
170                         ),
171                     ),
172                 )
173             )
174         );
175     }
176 }