4 * Class CRM_Core_BAO_MappingTest.
8 class CRM_Core_BAO_MappingTest
extends CiviUnitTestCase
{
13 * @throws \CRM_Core_Exception
15 public function tearDown() {
16 $this->quickCleanup(['civicrm_mapping_field', 'civicrm_mapping']);
21 * Test calling saveMapping.
23 * @dataProvider getMappingMaps
25 public function testSaveMappingFields($params, $expected) {
26 $mapping = $this->callAPISuccess('Mapping', 'create', ['name' => 'teest']);
27 CRM_Core_BAO_Mapping
::saveMappingFields($params, $mapping['id']);
28 $saved = $this->callAPISuccess('MappingField', 'get', ['mapping_id' => $mapping['id']])['values'];
29 $this->assertEquals($expected, $saved);
33 * Get data for mapping test.
37 public function getMappingMaps() {
41 'qfKey' => '8d3bae0f77b62314516c1253176a1c1a_6756',
42 'entryURL' => 'http://dmaster.local/civicrm/contribute/search?reset=1',
43 'saveMappingName' => 'test',
44 'saveMappingDesc' => '',
49 ['Individual', '10_b_a', 'id'],
50 ['Individual', 'city', ' '],
51 ['Individual', 'contact_sub_type'],
52 ['Student', 'custom_27'],
53 ['Individual', 'current_employer'],
54 ['Individual', 'phone', '1', '2'],
55 ['Individual', 'postal_code', '2'],
56 ['Individual', 'im', '1', '1'],
57 ['Individual', 'url'],
58 ['Individual', '1_b_a', 'phone', '5', '1'],
62 'expected' => $expected = [
68 'contact_type' => 'Individual',
69 'column_number' => '0',
70 'relationship_type_id' => '10',
71 'relationship_direction' => 'b_a',
79 'contact_type' => 'Individual',
80 'column_number' => '1',
87 'name' => 'contact_sub_type',
88 'contact_type' => 'Individual',
89 'column_number' => '2',
96 'name' => 'custom_27',
97 'contact_type' => 'Student',
98 'column_number' => '3',
105 'name' => 'current_employer',
106 'contact_type' => 'Individual',
107 'column_number' => '4',
115 'contact_type' => 'Individual',
116 'column_number' => '5',
117 'location_type_id' => '1',
118 'phone_type_id' => '2',
125 'name' => 'postal_code',
126 'contact_type' => 'Individual',
127 'column_number' => '6',
128 'location_type_id' => '2',
136 'contact_type' => 'Individual',
137 'column_number' => '7',
138 'location_type_id' => '1',
139 'im_provider_id' => '1',
147 'contact_type' => 'Individual',
148 'column_number' => '8',
156 'contact_type' => 'Individual',
157 'column_number' => '9',
158 'location_type_id' => '5',
159 'phone_type_id' => '1',
160 'relationship_type_id' => '1',
161 'relationship_direction' => 'b_a',
168 'qfKey' => '054b561dbf948548f7883151f879fe72_533',
169 'entryURL' => 'http://dmaster.local/civicrm/contact/search/builder?reset=1',
172 ['Contact', 'addressee_id'],
173 ['Individual', 'custom_2'],
178 [[''], [''], [''], [''], ['']],
179 [[''], [''], [''], [''], ['']],
182 ['IS NOT NULL', 'IS NULL', '', '', ''],
183 ['', '', '', '', ''],
184 ['', '', '', '', ''],
187 ['', '', '', '', ''],
188 ['', '', '', '', ''],
189 ['', '', '', '', ''],
192 'radio_ts' => 'ts_sel',
193 'toggleSelect' => '1',
202 'name' => 'addressee_id',
203 'contact_type' => 'Contact',
204 'column_number' => '0',
206 'operator' => 'IS NOT NULL',
211 'name' => 'custom_2',
212 'contact_type' => 'Individual',
213 'column_number' => '1',
215 'operator' => 'IS NULL',