Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Import_SavedMapping | |
31 | */ | |
025a13f3 | 32 | class WebTest_Import_SavedMappingTest extends ImportCiviSeleniumTestCase { |
6a488035 | 33 | |
6a488035 TO |
34 | protected function setUp() { |
35 | parent::setUp(); | |
36 | } | |
37 | ||
c490a46a | 38 | /** |
100fef9d | 39 | * Test Saved Import Mapping for Individuals. |
c490a46a | 40 | */ |
00be9182 | 41 | public function testSaveIndividualMapping() { |
6a488035 | 42 | |
6a488035 TO |
43 | // Logging in. |
44 | $this->webtestLogin(); | |
45 | ||
46 | // Get sample import data. | |
47 | list($headers, $rows) = $this->_individualCSVData(); | |
48 | ||
49 | // Create New Mapping Name | |
50 | $mappingName = 'contactimport_' . substr(sha1(rand()), 0, 7); | |
51 | ||
52 | $other = array( | |
53 | 'saveMapping' => TRUE, | |
54 | 'saveMappingName' => $mappingName, | |
55 | ); | |
56 | ||
57 | // Map Fields | |
58 | $fieldMapper = array( | |
aeaa5f5d JP |
59 | 'mapper[0][0]' => 'prefix_id', |
60 | 'mapper[4][0]' => 'suffix_id', | |
6a488035 TO |
61 | 'mapper[6][0]' => 'phone', |
62 | 'mapper[6][1]' => '5', | |
63 | 'mapper[7][0]' => 'supplemental_address_1', | |
64 | 'mapper[7][1]' => '5', | |
65 | 'mapper[8][0]' => 'supplemental_address_2', | |
66 | 'mapper[8][1]' => '5', | |
67 | 'mapper[9][0]' => 'city', | |
68 | 'mapper[9][1]' => '5', | |
69 | 'mapper[10][0]' => 'state_province', | |
70 | 'mapper[10][1]' => '5', | |
71 | 'mapper[11][0]' => 'country', | |
72 | 'mapper[11][1]' => '5', | |
73 | ); | |
74 | ||
75 | // Import and check Individual contacts in Skip mode. | |
76 | $this->importContacts($headers, $rows, 'Individual', 'Skip', $fieldMapper, $other); | |
77 | ||
78 | list($headers, $rows) = $this->_individualCSVData(); | |
79 | ||
80 | // Sending Mapped Name for Re-use | |
81 | $other = array('useMappingName' => $mappingName); | |
82 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
83 | } | |
84 | ||
4cbe18b8 | 85 | /** |
c490a46a CW |
86 | * Helper function to provide csv data for Individuals contact import. |
87 | * | |
4cbe18b8 EM |
88 | * @return array |
89 | */ | |
00be9182 | 90 | public function _individualCSVData() { |
6a488035 TO |
91 | $headers = array( |
92 | 'individual_prefix' => 'Individual Prefix', | |
93 | 'first_name' => 'First Name', | |
94 | 'middle_name' => 'Middle Name', | |
95 | 'last_name' => 'Last Name', | |
96 | 'individual_suffix' => 'Individual Suffix', | |
97 | 'email' => 'Email', | |
98 | 'phone' => 'Phone', | |
99 | 'address_1' => 'Additional Address 1', | |
100 | 'address_2' => 'Additional Address 2', | |
101 | 'city' => 'City', | |
102 | 'state' => 'State', | |
103 | 'country' => 'Country', | |
104 | ); | |
105 | ||
106 | $rows = array( | |
107 | array( | |
108 | 'individual_prefix' => 'Mr.', | |
109 | 'first_name' => substr(sha1(rand()), 0, 7), | |
110 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
111 | 'last_name' => 'Anderson', | |
112 | 'individual_suffix' => 'Jr.', | |
113 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
114 | 'phone' => '6949912154', | |
115 | 'address_1' => 'Add 1', | |
116 | 'address_2' => 'Add 2', | |
117 | 'city' => 'Watson', | |
118 | 'state' => 'NY', | |
86797006 | 119 | 'country' => 'UNITED STATES', |
6a488035 TO |
120 | ), |
121 | array( | |
122 | 'individual_prefix' => 'Mr.', | |
123 | 'first_name' => substr(sha1(rand()), 0, 7), | |
124 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
125 | 'last_name' => 'Summerson', | |
126 | 'individual_suffix' => 'Jr.', | |
127 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
128 | 'phone' => '6944412154', | |
129 | 'address_1' => 'Add 1', | |
130 | 'address_2' => 'Add 2', | |
131 | 'city' => 'Watson', | |
132 | 'state' => 'NY', | |
86797006 | 133 | 'country' => 'UNITED STATES', |
6a488035 TO |
134 | ), |
135 | ); | |
136 | ||
137 | return array($headers, $rows); | |
138 | } | |
96025800 | 139 | |
6a488035 | 140 | } |