2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 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('modules/Import/Importer.php');
39 require_once('modules/Calls/Call.php');
42 * Importing Calls will not populate Leads or Contacts Subpanel
44 * @author adetskin@sugarcrm.com
47 class Bug46411Test extends Sugar_PHPUnit_Framework_TestCase
50 * Importing Calls will not populate Leads or Contacts Subpanel
54 public function setUp()
56 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
58 $this->importSource = new stdClass();
59 $this->importSource->columncount = 2;
60 $this->importSource->colnum_0 = 'date_entered';
61 $this->importSource->colnum_1 = 'last_name';
62 $this->importSource->import_module = 'Calls';
63 $this->importSource->importlocale_charset = 'UTF-8';
64 $this->importSource->importlocale_dateformat = 'm/d/Y';
65 $this->importSource->importlocale_timeformat = 'h:i a';
66 $this->importSource->importlocale_timezone = 'GMT';
67 $this->importSource->importlocale_default_currency_significant_digits = '2';
68 $this->importSource->importlocale_currency = '-99';
69 $this->importSource->importlocale_dec_sep = '.';
70 $this->importSource->importlocale_currency = '-99';
71 $this->importSource->importlocale_default_locale_name_format = 's f l';
72 $this->importSource->importlocale_num_grp_sep = ',';
75 public function tearDown()
77 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
78 unset($GLOBALS['current_user']);
79 SugarTestLeadUtilities::removeAllCreatedLeads();
82 public function testMissingFields()
84 $bean = $this->getMock('Call',array(
85 'get_importable_fields',
86 'populateDefaultValues',
90 'writeRowToLastImport'));
92 $bean->expects($this->any())
93 ->method('get_importable_fields')
94 ->will($this->returnValue(array(
95 'account_id' => 'accounts',
96 'opportunity_id' => 'opportunities',
97 'contact_id' => 'contacts',
100 'assigned_user_id' => 'users',
101 'note_id' => 'notes',
102 'lead_id' => 'leads',
105 $bean->expects($this->any())
106 ->method('populateDefaultValues')
107 ->will($this->returnValue('foo'));
109 $bean->expects($this->any())
110 ->method('beforeImportSave')
111 ->will($this->returnValue('foo'));
113 $bean->expects($this->any())
115 ->will($this->returnValue('foo'));
117 $bean->expects($this->any())
118 ->method('afterImportSave')
119 ->will($this->returnValue('foo'));
121 $bean->expects($this->any())
122 ->method('writeRowToLastImport')
123 ->will($this->returnValue('foo'));
125 $bean->date_modified = 'true';
126 $bean->fetched_row = array('date_modified' => '');
127 $bean->object_name = '';
129 $lead = SugarTestLeadUtilities::createLead();
130 $a = new bug46411_Importer_mock($this->importSource, $bean);
133 $bean->parent_type = 'leads';
134 $bean->parent_id = $lead->id;
135 // $bean->relationship_fields = $b->relationship_fields;
137 $a->saveImportBean($bean, false);
138 $this->assertEquals($bean->parent_id, $bean->lead_id);
142 class bug46411_Importer_mock extends Importer
144 public function saveImportBean($focus, $newRecord)
146 return parent::saveImportBean($focus, $newRecord);