2 /*********************************************************************************
3 * By installing or using this file, you are confirming on behalf of the entity
4 * subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
5 * the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
6 * http://www.sugarcrm.com/master-subscription-agreement
8 * If Company is not bound by the MSA, then by installing or using this file
9 * you are agreeing unconditionally that Company will be bound by the MSA and
10 * certifying that you have authority to bind Company accordingly.
12 * Copyright (C) 2004-2013 SugarCRM Inc. All rights reserved.
13 ********************************************************************************/
16 require_once('modules/Import/Importer.php');
17 require_once('modules/Import/maps/ImportMap.php');
21 * saved import field mapping didn't work
24 * @author ekolotaev@sugarcrm.com
27 class Bug61172Test extends Sugar_PHPUnit_Framework_TestCase
31 public function setUp()
33 SugarTestHelper::setUp('current_user', array(true, 1));
34 $this->testFile = 'tests/modules/Tasks/Bug61172Test.csv';
38 'has_header' => 'off',
39 'firstrow' => base64_encode(serialize(array('0' => 'Foo', '1' => 'Status'))),
41 'colnum_1' => 'status',
43 'custom_enclosure' => '"',
44 'custom_delimiter' => ',',
46 'save_map_as' => 'Bug61172TestSaveMap',
48 // import settings values
49 'importlocale_charset' => 'UTF-8',
50 'importlocale_currency' => '-99',
51 'importlocale_dateformat' => 'd/m/Y',
52 'importlocale_dec_sep' => '.',
53 'importlocale_default_currency_significant_digits' => '2',
54 'importlocale_default_locale_name_format' => 's f l',
55 'importlocale_num_grp_sep' => ',',
56 'importlocale_timeformat' => 'H:i',
57 'importlocale_timezone' => 'Europe/Helsinki',
58 'import_module' => 'Leads',
62 public function tearDown()
64 SugarTestHelper::tearDown();
68 public function testSaveMappingFileSavesNumberFieldAssociationCorrectly()
71 $importSource = new ImportFile($this->testFile, ',', '', false);
72 $importer = new Bug61172TestImporterMock($importSource, $lead);
74 $importer->saveMappingFile();
75 $mappingFile = new ImportMap();
76 $mappingFile->retrieve_by_string_fields(array('name' => $_REQUEST['save_map_as']));
78 $this->assertNotEmpty($mappingFile->content);
80 $contentFields = explode('&', $mappingFile->content);
81 $this->assertContains('1=status', $contentFields, "Field status should be associated with #1");
83 $mappingFile->mark_deleted($mappingFile->id);
87 class Bug61172TestImporterMock extends Importer
89 public function saveMappingFile()
91 parent::saveMappingFile();