]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Leads/ConvertLeadTest.php
Merge pull request #126 from telematika/master
[Github/sugarcrm.git] / tests / modules / Leads / ConvertLeadTest.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/SugarTestViewConvertLeadUtilities.php');
39 require_once 'modules/Leads/views/view.convertlead.php';
40 require_once 'tests/SugarTestViewConvertLeadUtilities.php';
41
42
43 class ConvertLeadTest extends Sugar_PHPUnit_Framework_TestCase
44 {
45     public function setUp()
46     {
47         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
48         $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
49     }
50     
51     public function tearDown()
52     {
53         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
54         unset($GLOBALS['app_list_strings']);
55         unset($GLOBALS['current_user']);
56     }
57     
58     /**
59     * @group bug39787
60     */
61     public function testOpportunityNameValueFilled()
62     {
63         $lead = SugarTestLeadUtilities::createLead();
64         $lead->opportunity_name = 'SBizzle Dollar Store';
65         $lead->save();
66         
67         $_REQUEST['module'] = 'Leads';
68         $_REQUEST['action'] = 'ConvertLead';
69         $_REQUEST['record'] = $lead->id;
70         
71         // Check that the opportunity name doesn't get populated when it's not in the Leads editview layout
72         require_once('include/MVC/Controller/ControllerFactory.php');
73         require_once('include/MVC/View/ViewFactory.php');
74         $GLOBALS['app']->controller = ControllerFactory::getController($_REQUEST['module']);
75         ob_start();
76         $GLOBALS['app']->controller->execute();
77         $output = ob_get_clean();
78         
79         $matches_one = array();
80         $pattern = '/SBizzle Dollar Store/';
81         preg_match($pattern, $output, $matches_one);
82         $this->assertTrue(count($matches_one) == 0, "Opportunity name got carried over to the Convert Leads page when it shouldn't have.");
83
84         // Add the opportunity_name to the Leads EditView
85         SugarTestStudioUtilities::addFieldToLayout('Leads', 'editview', 'opportunity_name');
86         
87         // Check that the opportunity name now DOES get populated now that it's in the Leads editview layout
88         ob_start();
89         $GLOBALS['app']->controller = ControllerFactory::getController($_REQUEST['module']);
90         $GLOBALS['app']->controller->execute();
91         $output = ob_get_clean();
92         $matches_two = array();
93         $pattern = '/SBizzle Dollar Store/';
94         preg_match($pattern, $output, $matches_two);
95         $this->assertTrue(count($matches_two) > 0, "Opportunity name did not carry over to the Convert Leads page when it should have.");
96         
97         SugarTestStudioUtilities::removeAllCreatedFields();
98         unset($GLOBALS['app']->controller);
99         unset($_REQUEST['module']);
100         unset($_REQUEST['action']);
101         unset($_REQUEST['record']);
102         SugarTestLeadUtilities::removeAllCreatedLeads();
103     }
104
105     /**
106      * @group bug44033
107      */
108     public function testActivityMove() {
109         // init
110         $lead = SugarTestLeadUtilities::createLead();
111         $contact = SugarTestContactUtilities::createContact();
112         $meeting = SugarTestMeetingUtilities::createMeeting();
113         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
114         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
115         $_REQUEST['record'] = $lead->id;
116
117         // refresh the meeting to include parent_id and parent_type
118         $meeting_id = $meeting->id;
119         $meeting = new Meeting();
120         $meeting->retrieve($meeting_id);
121
122         // action: move meeting from lead to contact
123         $convertObj = new TestViewConvertLead();
124         $convertObj->moveActivityWrapper($meeting, $contact);
125
126         // verification 1, parent id should be contact id
127         $this->assertTrue($meeting->parent_id == $contact->id, 'Meeting parent id is not converted to contact id.');
128
129         // verification 2, parent type should be "Contacts"
130         $this->assertTrue($meeting->parent_type == 'Contacts', 'Meeting parent type is not converted to Contacts.');
131
132         // verification 3, record should be deleted from meetings_leads table
133         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
134         $result = $GLOBALS['db']->query($sql);
135         $row = $GLOBALS['db']->fetchByAssoc($result);
136         $this->assertFalse($row, "Meeting-Lead relationship is not removed.");
137
138         // verification 4, record should be added to meetings_contacts table
139         $sql = "select id from meetings_contacts where meeting_id='{$meeting->id}' and contact_id='{$contact->id}' and deleted=0";
140         $result = $GLOBALS['db']->query($sql);
141         $row = $GLOBALS['db']->fetchByAssoc($result);
142         $this->assertFalse(empty($row), "Meeting-Contact relationship is not added.");
143
144         // clean up
145         unset($_REQUEST['record']);
146         $GLOBALS['db']->query("delete from meetings_contacts where meeting_id='{$meeting->id}' and contact_id= '{$contact->id}'");
147         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
148         SugarTestMeetingUtilities::removeMeetingContacts();
149         SugarTestMeetingUtilities::removeAllCreatedMeetings();
150         SugarTestContactUtilities::removeAllCreatedContacts();
151         SugarTestLeadUtilities::removeAllCreatedLeads();
152     }
153
154
155     public function testActivityCopyWithParent() {
156         // lets the run the activity copy again, only this time we pass in a parent account
157         $lead = SugarTestLeadUtilities::createLead();
158         $contact = SugarTestContactUtilities::createContact();
159         $meeting = SugarTestMeetingUtilities::createMeeting();
160         $account = SugarTestAccountUtilities::createAccount();
161         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
162                 $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
163         $_REQUEST['record'] = $lead->id;
164
165         // refresh the meeting to include parent_id and parent_type
166         $meeting_id = $meeting->id;
167         $meeting = new Meeting();
168         $meeting->retrieve($meeting_id);
169
170         // action: copy meeting from lead to contact
171         $convertObj = new TestViewConvertLead();
172         $convertObj->copyActivityWrapper($meeting, $contact, array('id'=>$account->id,'type'=>'Accounts'));
173
174
175         // 2a a newly created meeting with no parent info passed in, so parent id and type are empty
176         //parent type=Contatcs and parent_id=$contact->id
177         //$sql = "select id from meetings where parent_id='{$contact->id}' and parent_type= 'Contacts' and deleted=0";
178         $sql = "select id, parent_id from meetings where name = '{$meeting->name}'";
179         $result = $GLOBALS['db']->query($sql);
180         while ($row = $GLOBALS['db']->fetchByAssoc($result)){
181             //skip if this is the original message
182             if($row['id'] == $meeting_id){
183                 continue;
184             }
185
186             $this->assertEquals($row['parent_id'], $account->id, 'parent id of meeting should be equal to passed in account id: '.$account->id);
187         }
188
189     }
190
191     
192     public function testActivityCopyWithNoParent() {
193         // init
194         $lead = SugarTestLeadUtilities::createLead();
195         $contact = SugarTestContactUtilities::createContact();
196         $meeting = SugarTestMeetingUtilities::createMeeting();
197         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
198         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
199         $_REQUEST['record'] = $lead->id;
200
201         // refresh the meeting to include parent_id and parent_type
202         $meeting_id = $meeting->id;
203         $meeting = new Meeting();
204         $meeting->retrieve($meeting_id);
205
206         // action: copy meeting from lead to contact
207         $convertObj = new TestViewConvertLead();
208         $convertObj->copyActivityWrapper($meeting, $contact);
209
210         // 1. the original meeting should still have the same parent_type and parent_id
211         $meeting->retrieve($meeting_id);
212         $this->assertEquals('Leads', $meeting->parent_type, 'parent_type of the original meeting was changed from Leads to '.$meeting->parent_type);
213         $this->assertEquals($lead->id, $meeting->parent_id, 'parent_id of the original meeting was changed from '.$lead->id.' to '.$meeting->parent_id);
214
215         // 2. a newly created meeting with no parent info passed in, so parent id and type are empty
216         $new_meeting_id = '';
217         $sql = "select id, parent_id from meetings where name = '{$meeting->name}'";
218               $result = $GLOBALS['db']->query($sql);
219               while ($row = $GLOBALS['db']->fetchByAssoc($result)){
220                   //skip if this is the original message
221                   if($row['id'] == $meeting_id){
222                       continue;
223                   }
224                   $new_meeting_id = $row['id'];
225                   $this->assertEmpty($row['parent_id'],'parent id of meeting should be empty as no parent was sent in ');
226               }
227
228
229
230         // 3. record should not be deleted from meetings_leads table
231         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
232         $result = $GLOBALS['db']->query($sql);
233         $row = $GLOBALS['db']->fetchByAssoc($result);
234         $this->assertNotNull($row, "Meeting-Lead relationship was removed.");
235
236         // 4. new meeting record should be added to meetings_contacts table
237         $sql = "select id from meetings_contacts where meeting_id='{$new_meeting_id}' and contact_id='{$contact->id}' and deleted=0";
238         $result = $GLOBALS['db']->query($sql);
239         $row = $GLOBALS['db']->fetchByAssoc($result);
240         $this->assertFalse(empty($row), "Meeting-Contact relationship has not been added.");
241
242         // clean up
243         unset($_REQUEST['record']);
244         $GLOBALS['db']->query("delete from meetings where parent_id='{$contact->id}' and parent_type= 'Contacts'");
245         $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
246         $GLOBALS['db']->query("delete from meetings_contacts where meeting_id='{$new_meeting_id}' and contact_id= '{$contact->id}'");
247         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
248         SugarTestMeetingUtilities::removeMeetingContacts();
249         SugarTestMeetingUtilities::removeAllCreatedMeetings();
250         SugarTestContactUtilities::removeAllCreatedContacts();
251         SugarTestLeadUtilities::removeAllCreatedLeads();
252     }
253
254     /**
255      * @outputBuffering enabled
256      */
257     public function testConversionAndMoveActivities() {
258         global $sugar_config;
259
260         // init
261         $lead = SugarTestLeadUtilities::createLead();
262         $account = SugarTestAccountUtilities::createAccount();
263         $meeting = SugarTestMeetingUtilities::createMeeting();
264         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
265         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
266         $_REQUEST['record'] = $lead->id;
267
268         // set the request/post parameters before converting the lead
269         $_REQUEST['module'] = 'Leads';
270         $_REQUEST['action'] = 'ConvertLead';
271         $_REQUEST['record'] = $lead->id;
272         $_REQUEST['handle'] = 'save';
273         $_REQUEST['selectedAccount'] = $account->id;
274         $sugar_config['lead_conv_activity_opt'] = 'move';
275         $_POST['lead_conv_ac_op_sel'] = 'Contacts';
276
277         // call display to trigger conversion
278         $vc = new ViewConvertLead();
279         $vc->display();
280
281         // refresh meeting
282         $meeting_id = $meeting->id;
283         $meeting = new Meeting();
284         $meeting->retrieve($meeting_id);
285
286         // refresh lead
287         $lead_id = $lead->id;
288         $lead = new Lead();
289         $lead->retrieve($lead_id);
290
291         // retrieve the new contact id from the conversion
292         $contact_id = $lead->contact_id;
293
294         // 1. Lead's contact_id should not be null
295         $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.');
296
297         // 2. Lead status should be 'Converted'
298         $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'.");
299
300         // 3. new parent_type should be Contacts
301         $this->assertEquals('Contacts', $meeting->parent_type, 'Meeting parent type has not been set to Contacts');
302
303         // 4. new parent_id should be contact id
304         $this->assertEquals($contact_id, $meeting->parent_id, 'Meeting parent id has not been set to contact id.');
305
306         // 5. record should be deleted from meetings_leads table
307         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
308         $result = $GLOBALS['db']->query($sql);
309         $row = $GLOBALS['db']->fetchByAssoc($result);
310         $this->assertFalse($row, "Meeting-Lead relationship is not removed.");
311
312         // 6. record should be added to meetings_contacts table
313         $sql = "select id from meetings_contacts where meeting_id='{$meeting->id}' and contact_id='{$contact_id}' and deleted=0";
314         $result = $GLOBALS['db']->query($sql);
315         $row = $GLOBALS['db']->fetchByAssoc($result);
316         $this->assertFalse(empty($row), "Meeting-Contact relationship is not added.");
317
318         // clean up
319         unset($_REQUEST['record']);
320         $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
321         $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'");
322         $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'");
323         $GLOBALS['db']->query("delete from meetings_contacts where meeting_id='{$meeting->id}' and contact_id= '{$contact_id}'");
324         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
325         SugarTestMeetingUtilities::removeMeetingContacts();
326         SugarTestMeetingUtilities::removeAllCreatedMeetings();
327         SugarTestAccountUtilities::removeAllCreatedAccounts();
328         SugarTestLeadUtilities::removeAllCreatedLeads();
329     }
330
331     /**
332      * @outputBuffering enabled
333      */
334     public function testConversionAndCopyActivities() {
335         global $sugar_config;
336
337         // init
338         $lead = SugarTestLeadUtilities::createLead();
339         $account = SugarTestAccountUtilities::createAccount();
340         $meeting = SugarTestMeetingUtilities::createMeeting();
341         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
342         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
343         $_REQUEST['record'] = $lead->id;
344
345         // set the request/post parameters before converting the lead
346         $_REQUEST['module'] = 'Leads';
347         $_REQUEST['action'] = 'ConvertLead';
348         $_REQUEST['record'] = $lead->id;
349         $_REQUEST['handle'] = 'save';
350         $_REQUEST['selectedAccount'] = $account->id;
351         $sugar_config['lead_conv_activity_opt'] = 'copy';
352         $_POST['lead_conv_ac_op_sel'] = array('Contacts');
353
354         // call display to trigger conversion
355         $vc = new ViewConvertLead();
356         $vc->display();
357
358         // refresh meeting
359         $meeting_id = $meeting->id;
360         $meeting = new Meeting();
361         $meeting->retrieve($meeting_id);
362
363         // refresh lead
364         $lead_id = $lead->id;
365         $lead = new Lead();
366         $lead->retrieve($lead_id);
367
368         // retrieve the new contact id from the conversion
369         $contact_id = $lead->contact_id;
370
371         // 1. Lead's contact_id should not be null
372         $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.');
373
374         // 2. Lead status should be 'Converted'
375         $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'.");
376
377         // 3. parent_type of the original meeting should be Leads
378         $this->assertEquals('Leads', $meeting->parent_type, 'Meeting parent should be Leads');
379
380         // 4. parent_id of the original meeting should be contact id
381         $this->assertEquals($lead_id, $meeting->parent_id, 'Meeting parent id should be lead id.');
382
383         // 5. record should NOT be deleted from meetings_leads table
384         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
385         $result = $GLOBALS['db']->query($sql);
386         $row = $GLOBALS['db']->fetchByAssoc($result);
387         $this->assertFalse(empty($row), "Meeting-Lead relationship is removed.");
388
389         // 6. record should be added to meetings_contacts table
390         $sql = "select meeting_id from meetings_contacts where contact_id='{$contact_id}' and deleted=0";
391         $result = $GLOBALS['db']->query($sql);
392         $row = $GLOBALS['db']->fetchByAssoc($result);
393         $this->assertFalse(empty($row), "Meeting-Contact relationship is not added.");
394
395         // 7. the parent_type of the new meeting should be empty
396         $new_meeting_id = $row['meeting_id'];
397         $sql = "select id, parent_type, parent_id from meetings where id='{$new_meeting_id}' and deleted=0";
398         $result = $GLOBALS['db']->query($sql);
399         $row = $GLOBALS['db']->fetchByAssoc($result);
400         $this->assertFalse(empty($row), "New meeting is not added for contact.");
401         $this->assertEmpty($row['parent_type'], 'Parent type of the new meeting should be Empty');
402
403         // 8. the parent_id of the new meeting should be contact id
404         $this->assertEmpty($row['parent_id'], 'Parent id of the new meeting should be empty.');
405
406        // clean up
407         unset($_REQUEST['record']);
408         $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
409         $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'");
410         $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'");
411         $GLOBALS['db']->query("delete from meetings_leads where meeting_id='{$meeting->id}' and lead_id= '{$lead_id}'");
412         $GLOBALS['db']->query("delete from meetings_contacts where contact_id= '{$contact_id}'");
413         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
414         SugarTestMeetingUtilities::removeMeetingContacts();
415         SugarTestMeetingUtilities::removeAllCreatedMeetings();
416         SugarTestAccountUtilities::removeAllCreatedAccounts();
417         SugarTestLeadUtilities::removeAllCreatedLeads();
418     }
419
420     /**
421      * @outputBuffering enabled
422      */
423     public function testConversionAndDoNothing() {
424         global $sugar_config;
425
426         // init
427         $lead = SugarTestLeadUtilities::createLead();
428         $account = SugarTestAccountUtilities::createAccount();
429         $meeting = SugarTestMeetingUtilities::createMeeting();
430         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
431         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
432         $_REQUEST['record'] = $lead->id;
433
434         // set the request/post parameters before converting the lead
435         $_REQUEST['module'] = 'Leads';
436         $_REQUEST['action'] = 'ConvertLead';
437         $_REQUEST['record'] = $lead->id;
438         $_REQUEST['handle'] = 'save';
439         $_REQUEST['selectedAccount'] = $account->id;
440         $sugar_config['lead_conv_activity_opt'] = 'none';
441
442         // call display to trigger conversion
443         $vc = new ViewConvertLead();
444         $vc->display();
445
446         // refresh meeting
447         $meeting_id = $meeting->id;
448         $meeting = new Meeting();
449         $meeting->retrieve($meeting_id);
450
451         // refresh lead
452         $lead_id = $lead->id;
453         $lead = new Lead();
454         $lead->retrieve($lead_id);
455
456         // retrieve the new contact id from the conversion
457         $contact_id = $lead->contact_id;
458
459         // 1. Lead's contact_id should not be null
460         $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.');
461
462         // 2. Lead status should be 'Converted'
463         $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'.");
464
465         // 3. parent_type of the original meeting should be Leads
466         $this->assertEquals('Leads', $meeting->parent_type, 'Meeting parent should be Leads');
467
468         // 4. parent_id of the original meeting should be contact id
469         $this->assertEquals($lead_id, $meeting->parent_id, 'Meeting parent id should be lead id.');
470
471         // 5. record should NOT be deleted from meetings_leads table
472         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
473         $result = $GLOBALS['db']->query($sql);
474         $row = $GLOBALS['db']->fetchByAssoc($result);
475         $this->assertFalse(empty($row), "Meeting-Lead relationship is removed.");
476
477         // 6. record should NOT be added to meetings_contacts table
478         $sql = "select meeting_id from meetings_contacts where contact_id='{$contact_id}' and deleted=0";
479         $result = $GLOBALS['db']->query($sql);
480         $row = $GLOBALS['db']->fetchByAssoc($result);
481         $this->assertFalse($row, "Meeting-Contact relationship should not be added.");
482
483         // clean up
484         unset($_REQUEST['record']);
485         $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
486         $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'");
487         $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'");
488         $GLOBALS['db']->query("delete from meetings_leads where meeting_id='{$meeting->id}' and lead_id= '{$lead_id}'");
489         $GLOBALS['db']->query("delete from meetings_contacts where contact_id= '{$contact_id}'");
490         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
491         SugarTestMeetingUtilities::removeMeetingContacts();
492         SugarTestMeetingUtilities::removeAllCreatedMeetings();
493         SugarTestAccountUtilities::removeAllCreatedAccounts();
494         SugarTestLeadUtilities::removeAllCreatedLeads();
495     }
496
497     public function testMeetingsUsersRelationships()
498     {
499         global $current_user;
500
501         $bean = SugarTestMeetingUtilities::createMeeting();
502         $convert_lead = SugarTestViewConvertLeadUtilities::createViewConvertLead();
503
504         if ($bean->object_name == "Meeting")
505         {
506             $convert_lead->setMeetingsUsersRelationship($bean);
507         }
508
509         $this->assertTrue(is_object($bean->users), "Relationship wasn't set.");
510
511         SugarTestMeetingUtilities::removeMeetingUsers();
512         SugarTestMeetingUtilities::removeAllCreatedMeetings();
513     }
514 }
515
516 class TestViewConvertLead extends ViewConvertLead
517 {
518     public function moveActivityWrapper($activity, $bean) {
519         parent::moveActivity($activity, $bean);
520     }
521
522     public function copyActivityWrapper($activity, $bean,$parent=array()) {
523         parent::copyActivityAndRelateToBean($activity, $bean,$parent);
524     }
525
526     public function testMeetingsUsersRelationships()
527     {
528         global $current_user;
529         
530         $bean = SugarTestMeetingUtilities::createMeeting();
531         $convert_lead = SugarTestViewConvertLeadUtilities::createViewConvertLead();
532         
533         if ($bean->object_name == "Meeting")
534         {
535             $convert_lead->setMeetingsUsersRelationship($bean);
536         }
537         
538         $this->assertTrue(is_object($bean->users), "Relationship wasn't set.");
539         
540         SugarTestMeetingUtilities::removeMeetingUsers();
541         SugarTestMeetingUtilities::removeAllCreatedMeetings();
542     }
543 }