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('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 $this->markTestIncomplete("Breaking unit test on CI");
59 $this->importSource = new stdClass();
60 $this->importSource->columncount = 2;
61 $this->importSource->colnum_0 = 'date_entered';
62 $this->importSource->colnum_1 = 'last_name';
63 $this->importSource->import_module = 'Calls';
64 $this->importSource->importlocale_charset = 'UTF-8';
65 $this->importSource->importlocale_dateformat = 'm/d/Y';
66 $this->importSource->importlocale_timeformat = 'h:i a';
67 $this->importSource->importlocale_timezone = 'GMT';
68 $this->importSource->importlocale_default_currency_significant_digits = '2';
69 $this->importSource->importlocale_currency = '-99';
70 $this->importSource->importlocale_dec_sep = '.';
71 $this->importSource->importlocale_currency = '-99';
72 $this->importSource->importlocale_default_locale_name_format = 's f l';
73 $this->importSource->importlocale_num_grp_sep = ',';
76 public function tearDown()
78 SugarTestLeadUtilities::removeAllCreatedLeads();
81 public function testMissingFields()
83 $bean = $this->getMock('Call',array(
84 'get_importable_fields',
85 'populateDefaultValues',
89 'writeRowToLastImport'));
91 $bean->expects($this->any())
92 ->method('get_importable_fields')
93 ->will($this->returnValue(array(
94 'account_id' => 'accounts',
95 'opportunity_id' => 'opportunities',
96 'contact_id' => 'contacts',
99 'assigned_user_id' => 'users',
100 'note_id' => 'notes',
101 'lead_id' => 'leads',
104 $bean->expects($this->any())
105 ->method('populateDefaultValues')
106 ->will($this->returnValue('foo'));
108 $bean->expects($this->any())
109 ->method('beforeImportSave')
110 ->will($this->returnValue('foo'));
112 $bean->expects($this->any())
114 ->will($this->returnValue('foo'));
116 $bean->expects($this->any())
117 ->method('afterImportSave')
118 ->will($this->returnValue('foo'));
120 $bean->expects($this->any())
121 ->method('writeRowToLastImport')
122 ->will($this->returnValue('foo'));
124 $bean->date_modified = 'true';
125 $bean->fetched_row = array('date_modified' => '');
126 $bean->object_name = '';
128 $lead = SugarTestLeadUtilities::createLead();
129 $a = new bug46411_Importer_mock($this->importSource, $bean);
132 $bean->parent_type = 'leads';
133 $bean->parent_id = $lead->id;
134 // $bean->relationship_fields = $b->relationship_fields;
136 $a->saveImportBean($bean, false);
137 $this->assertEquals($bean->parent_id, $bean->lead_id);
141 class bug46411_Importer_mock extends Importer
143 public function saveImportBean($focus, $newRecord)
145 return parent::saveImportBean($focus, $newRecord);