]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Leads/ConvertLeadTests.php
Merge pull request #126 from telematika/master
[Github/sugarcrm.git] / tests / modules / Leads / ConvertLeadTests.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 ConvertLeadTests 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     public function testConversionAndMoveActivities() {
255         global $sugar_config;
256
257         // init
258         $lead = SugarTestLeadUtilities::createLead();
259         $account = SugarTestAccountUtilities::createAccount();
260         $meeting = SugarTestMeetingUtilities::createMeeting();
261         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
262         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
263         $_REQUEST['record'] = $lead->id;
264
265         // set the request/post parameters before converting the lead
266         $_REQUEST['module'] = 'Leads';
267         $_REQUEST['action'] = 'ConvertLead';
268         $_REQUEST['record'] = $lead->id;
269         $_REQUEST['handle'] = 'save';
270         $_REQUEST['selectedAccount'] = $account->id;
271         $sugar_config['lead_conv_activity_opt'] = 'move';
272         $_POST['lead_conv_ac_op_sel'] = 'Contacts';
273
274         // call display to trigger conversion
275         $vc = new ViewConvertLead();
276         $vc->display();
277
278         // refresh meeting
279         $meeting_id = $meeting->id;
280         $meeting = new Meeting();
281         $meeting->retrieve($meeting_id);
282
283         // refresh lead
284         $lead_id = $lead->id;
285         $lead = new Lead();
286         $lead->retrieve($lead_id);
287
288         // retrieve the new contact id from the conversion
289         $contact_id = $lead->contact_id;
290
291         // 1. Lead's contact_id should not be null
292         $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.');
293
294         // 2. Lead status should be 'Converted'
295         $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'.");
296
297         // 3. new parent_type should be Contacts
298         $this->assertEquals('Contacts', $meeting->parent_type, 'Meeting parent type has not been set to Contacts');
299
300         // 4. new parent_id should be contact id
301         $this->assertEquals($contact_id, $meeting->parent_id, 'Meeting parent id has not been set to contact id.');
302
303         // 5. record should be deleted from meetings_leads table
304         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
305         $result = $GLOBALS['db']->query($sql);
306         $row = $GLOBALS['db']->fetchByAssoc($result);
307         $this->assertFalse($row, "Meeting-Lead relationship is not removed.");
308
309         // 6. record should be added to meetings_contacts table
310         $sql = "select id from meetings_contacts where meeting_id='{$meeting->id}' and contact_id='{$contact_id}' and deleted=0";
311         $result = $GLOBALS['db']->query($sql);
312         $row = $GLOBALS['db']->fetchByAssoc($result);
313         $this->assertFalse(empty($row), "Meeting-Contact relationship is not added.");
314
315         // clean up
316         unset($_REQUEST['record']);
317         $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
318         $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'");
319         $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'");
320         $GLOBALS['db']->query("delete from meetings_contacts where meeting_id='{$meeting->id}' and contact_id= '{$contact_id}'");
321         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
322         SugarTestMeetingUtilities::removeMeetingContacts();
323         SugarTestMeetingUtilities::removeAllCreatedMeetings();
324         SugarTestAccountUtilities::removeAllCreatedAccounts();
325         SugarTestLeadUtilities::removeAllCreatedLeads();
326     }
327
328     public function testConversionAndCopyActivities() {
329         global $sugar_config;
330
331         // init
332         $lead = SugarTestLeadUtilities::createLead();
333         $account = SugarTestAccountUtilities::createAccount();
334         $meeting = SugarTestMeetingUtilities::createMeeting();
335         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
336         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
337         $_REQUEST['record'] = $lead->id;
338
339         // set the request/post parameters before converting the lead
340         $_REQUEST['module'] = 'Leads';
341         $_REQUEST['action'] = 'ConvertLead';
342         $_REQUEST['record'] = $lead->id;
343         $_REQUEST['handle'] = 'save';
344         $_REQUEST['selectedAccount'] = $account->id;
345         $sugar_config['lead_conv_activity_opt'] = 'copy';
346         $_POST['lead_conv_ac_op_sel'] = array('Contacts');
347
348         // call display to trigger conversion
349         $vc = new ViewConvertLead();
350         $vc->display();
351
352         // refresh meeting
353         $meeting_id = $meeting->id;
354         $meeting = new Meeting();
355         $meeting->retrieve($meeting_id);
356
357         // refresh lead
358         $lead_id = $lead->id;
359         $lead = new Lead();
360         $lead->retrieve($lead_id);
361
362         // retrieve the new contact id from the conversion
363         $contact_id = $lead->contact_id;
364
365         // 1. Lead's contact_id should not be null
366         $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.');
367
368         // 2. Lead status should be 'Converted'
369         $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'.");
370
371         // 3. parent_type of the original meeting should be Leads
372         $this->assertEquals('Leads', $meeting->parent_type, 'Meeting parent should be Leads');
373
374         // 4. parent_id of the original meeting should be contact id
375         $this->assertEquals($lead_id, $meeting->parent_id, 'Meeting parent id should be lead id.');
376
377         // 5. record should NOT be deleted from meetings_leads table
378         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
379         $result = $GLOBALS['db']->query($sql);
380         $row = $GLOBALS['db']->fetchByAssoc($result);
381         $this->assertFalse(empty($row), "Meeting-Lead relationship is removed.");
382
383         // 6. record should be added to meetings_contacts table
384         $sql = "select meeting_id from meetings_contacts where contact_id='{$contact_id}' and deleted=0";
385         $result = $GLOBALS['db']->query($sql);
386         $row = $GLOBALS['db']->fetchByAssoc($result);
387         $this->assertFalse(empty($row), "Meeting-Contact relationship is not added.");
388
389         // 7. the parent_type of the new meeting should be empty
390         $new_meeting_id = $row['meeting_id'];
391         $sql = "select id, parent_type, parent_id from meetings where id='{$new_meeting_id}' and deleted=0";
392         $result = $GLOBALS['db']->query($sql);
393         $row = $GLOBALS['db']->fetchByAssoc($result);
394         $this->assertFalse(empty($row), "New meeting is not added for contact.");
395         $this->assertEmpty($row['parent_type'], 'Parent type of the new meeting should be Empty');
396
397         // 8. the parent_id of the new meeting should be contact id
398         $this->assertEmpty($row['parent_id'], 'Parent id of the new meeting should be empty.');
399
400        // clean up
401         unset($_REQUEST['record']);
402         $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
403         $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'");
404         $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'");
405         $GLOBALS['db']->query("delete from meetings_leads where meeting_id='{$meeting->id}' and lead_id= '{$lead_id}'");
406         $GLOBALS['db']->query("delete from meetings_contacts where contact_id= '{$contact_id}'");
407         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
408         SugarTestMeetingUtilities::removeMeetingContacts();
409         SugarTestMeetingUtilities::removeAllCreatedMeetings();
410         SugarTestAccountUtilities::removeAllCreatedAccounts();
411         SugarTestLeadUtilities::removeAllCreatedLeads();
412     }
413
414     public function testConversionAndDoNothing() {
415         global $sugar_config;
416
417         // init
418         $lead = SugarTestLeadUtilities::createLead();
419         $account = SugarTestAccountUtilities::createAccount();
420         $meeting = SugarTestMeetingUtilities::createMeeting();
421         SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
422         $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
423         $_REQUEST['record'] = $lead->id;
424
425         // set the request/post parameters before converting the lead
426         $_REQUEST['module'] = 'Leads';
427         $_REQUEST['action'] = 'ConvertLead';
428         $_REQUEST['record'] = $lead->id;
429         $_REQUEST['handle'] = 'save';
430         $_REQUEST['selectedAccount'] = $account->id;
431         $sugar_config['lead_conv_activity_opt'] = 'none';
432
433         // call display to trigger conversion
434         $vc = new ViewConvertLead();
435         $vc->display();
436
437         // refresh meeting
438         $meeting_id = $meeting->id;
439         $meeting = new Meeting();
440         $meeting->retrieve($meeting_id);
441
442         // refresh lead
443         $lead_id = $lead->id;
444         $lead = new Lead();
445         $lead->retrieve($lead_id);
446
447         // retrieve the new contact id from the conversion
448         $contact_id = $lead->contact_id;
449
450         // 1. Lead's contact_id should not be null
451         $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.');
452
453         // 2. Lead status should be 'Converted'
454         $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'.");
455
456         // 3. parent_type of the original meeting should be Leads
457         $this->assertEquals('Leads', $meeting->parent_type, 'Meeting parent should be Leads');
458
459         // 4. parent_id of the original meeting should be contact id
460         $this->assertEquals($lead_id, $meeting->parent_id, 'Meeting parent id should be lead id.');
461
462         // 5. record should NOT be deleted from meetings_leads table
463         $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
464         $result = $GLOBALS['db']->query($sql);
465         $row = $GLOBALS['db']->fetchByAssoc($result);
466         $this->assertFalse(empty($row), "Meeting-Lead relationship is removed.");
467
468         // 6. record should NOT be added to meetings_contacts table
469         $sql = "select meeting_id from meetings_contacts where contact_id='{$contact_id}' and deleted=0";
470         $result = $GLOBALS['db']->query($sql);
471         $row = $GLOBALS['db']->fetchByAssoc($result);
472         $this->assertFalse($row, "Meeting-Contact relationship should not be added.");
473
474         // clean up
475         unset($_REQUEST['record']);
476         $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
477         $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'");
478         $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'");
479         $GLOBALS['db']->query("delete from meetings_leads where meeting_id='{$meeting->id}' and lead_id= '{$lead_id}'");
480         $GLOBALS['db']->query("delete from meetings_contacts where contact_id= '{$contact_id}'");
481         SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
482         SugarTestMeetingUtilities::removeMeetingContacts();
483         SugarTestMeetingUtilities::removeAllCreatedMeetings();
484         SugarTestAccountUtilities::removeAllCreatedAccounts();
485         SugarTestLeadUtilities::removeAllCreatedLeads();
486     }
487
488     public function testMeetingsUsersRelationships()
489     {
490         global $current_user;
491
492         $bean = SugarTestMeetingUtilities::createMeeting();
493         $convert_lead = SugarTestViewConvertLeadUtilities::createViewConvertLead();
494
495         if ($bean->object_name == "Meeting")
496         {
497             $convert_lead->setMeetingsUsersRelationship($bean);
498         }
499
500         $this->assertTrue(is_object($bean->users), "Relationship wasn't set.");
501
502         SugarTestMeetingUtilities::removeMeetingUsers();
503         SugarTestMeetingUtilities::removeAllCreatedMeetings();
504     }
505 }
506
507 class TestViewConvertLead extends ViewConvertLead
508 {
509     public function moveActivityWrapper($activity, $bean) {
510         parent::moveActivity($activity, $bean);
511     }
512
513     public function copyActivityWrapper($activity, $bean,$parent=array()) {
514         parent::copyActivityAndRelateToBean($activity, $bean,$parent);
515     }
516
517     public function testMeetingsUsersRelationships()
518     {
519         global $current_user;
520         
521         $bean = SugarTestMeetingUtilities::createMeeting();
522         $convert_lead = SugarTestViewConvertLeadUtilities::createViewConvertLead();
523         
524         if ($bean->object_name == "Meeting")
525         {
526             $convert_lead->setMeetingsUsersRelationship($bean);
527         }
528         
529         $this->assertTrue(is_object($bean->users), "Relationship wasn't set.");
530         
531         SugarTestMeetingUtilities::removeMeetingUsers();
532         SugarTestMeetingUtilities::removeAllCreatedMeetings();
533     }
534 }