]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Import/Bug46411Test.php
Release 6.4.4
[Github/sugarcrm.git] / tests / modules / Import / Bug46411Test.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('modules/Import/Importer.php');
39 require_once('modules/Calls/Call.php');
40 /**
41  * Bug #46411
42  * Importing Calls will not populate Leads or Contacts Subpanel
43  *
44  * @author adetskin@sugarcrm.com
45  * @ticket 46411
46  */
47 class Bug46411Test extends Sugar_PHPUnit_Framework_TestCase
48 {
49     /**
50      * Importing Calls will not populate Leads or Contacts Subpanel
51      *
52      * @group 46411
53      */
54     public function setUp()
55     {
56         $this->markTestIncomplete("Breaking unit test on CI");
57         return;
58
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 = ',';
74     }
75
76     public function tearDown()
77     {
78         SugarTestLeadUtilities::removeAllCreatedLeads();
79     }
80
81     public function testMissingFields()
82     {
83         $bean = $this->getMock('Call',array(
84             'get_importable_fields',
85             'populateDefaultValues',
86             'beforeImportSave',
87             'save',
88             'afterImportSave',
89             'writeRowToLastImport'));
90
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',
97             'case_id'                   => 'cases',
98             'user_id'                   => 'users',
99             'assigned_user_id'  => 'users',
100             'note_id'                   => 'notes',
101             'lead_id'                   => 'leads',
102         )));
103
104         $bean->expects($this->any())
105             ->method('populateDefaultValues')
106             ->will($this->returnValue('foo'));
107
108         $bean->expects($this->any())
109             ->method('beforeImportSave')
110             ->will($this->returnValue('foo'));
111
112         $bean->expects($this->any())
113             ->method('save')
114             ->will($this->returnValue('foo'));
115
116         $bean->expects($this->any())
117             ->method('afterImportSave')
118             ->will($this->returnValue('foo'));
119
120         $bean->expects($this->any())
121             ->method('writeRowToLastImport')
122             ->will($this->returnValue('foo'));
123
124         $bean->date_modified = 'true';
125         $bean->fetched_row = array('date_modified' => '');
126         $bean->object_name = '';
127
128         $lead = SugarTestLeadUtilities::createLead();
129         $a = new bug46411_Importer_mock($this->importSource, $bean);
130 //        $b = new Call();
131
132         $bean->parent_type = 'leads';
133         $bean->parent_id = $lead->id;
134 //        $bean->relationship_fields = $b->relationship_fields;
135
136         $a->saveImportBean($bean, false);
137         $this->assertEquals($bean->parent_id, $bean->lead_id);
138     }
139 }
140
141 class bug46411_Importer_mock extends Importer
142 {
143     public function saveImportBean($focus, $newRecord)
144     {
145         return parent::saveImportBean($focus, $newRecord);
146     }
147
148 }
149
150