$result = $this->_doImport(array(), $definition);
$this->assertEquals(1, $result['updatecount'], 'should have updated 1 contact');
- $this->assertEquals(0, $result['totalcount']);
+ $this->assertEquals(0, $result['totalcount'], 'should have imported 0 records: ' . print_r($result['results']->toArray(), true));
$this->assertEquals(0, $result['failcount']);
$this->assertEquals('joerg@home.com', $result['results'][0]->email_home, 'duplicates resolving did not work: ' . print_r($result['results']->toArray(), true));
$this->assertEquals('Jörg', $result['results'][0]->n_given, 'wrong encoding: ' . print_r($result['results']->toArray(), true));
{
$this->_createCustomField('customfield1');
$this->_createCustomField('customfield2');
+ // empty values: should not trigger record updates
+ $this->_createCustomField('customfield3');
$result = $this->testImportDuplicateResolve(/* $withCustomfields */ true);
$this->assertEquals('Straßbough', $result['results'][1]['adr_one_locality'],
'should have changed the locality of contact #2: ' . print_r($result['results'][1]->toArray(), true));
$this->assertEquals('Gartencenter Röhr & Vater', $result['results'][3]['n_family']);
-
- // TODO this should be researched, imho the relation should not trigger an update of the record
-// $this->assertEquals(1, $result['results'][3]['seq'], 'Wolfer has been updated - relations changed');
-// $this->assertEquals('Weixdorf DD', $result['results'][0]['adr_one_locality'], 'locality should persist');
-// $this->assertEquals('Gartencenter Röhr & Vater', $result['results'][4]['n_fileas']);
-// $this->assertEquals('Straßback', $result['results'][5]['adr_one_locality']);
}
public function testSplitField()
<source>customfield2</source>
<destination>customfield2</destination>
</field>
+ <field>
+ <source>customfield3</source>
+ <destination>customfield3</destination>
+ </field>
</mapping>
</config>
\ No newline at end of file
-"org_name","salutation","title","n_given","n_family","role","adr_one_street","adr_one_postalcode","adr_one_locality","adr_one_countryname","tel_work","tel_fax","tel_cell","email","tel_fax_home","tel_home","email_home","customfield1","customfield2"\r
-"effect gmbh","Herr","Dr.","Jörg","Heinz","Geschäftsführer","Str. 25","21222","Köln","DE","022324321","","","joerg.heinz@honk.com","","","","cf1","cf2"\r
-"effect gmbh","Herr","","Hans","Fritz","Technical Lead","Str. 25","21222","Köln","DE","022324321","","","hans.fritz@honk.com","","","","cf1","cf2"\r
+"org_name","salutation","title","n_given","n_family","role","adr_one_street","adr_one_postalcode","adr_one_locality","adr_one_countryname","tel_work","tel_fax","tel_cell","email","tel_fax_home","tel_home","email_home","customfield1","customfield2","customfield3"
+"effect gmbh","Herr","Dr.","Jörg","Heinz","Geschäftsführer","Str. 25","21222","Köln","DE","022324321","","","joerg.heinz@honk.com","","","","cf1","cf2",""
+"effect gmbh","Herr","","Hans","Fritz","Technical Lead","Str. 25","21222","Köln","DE","022324321","","","hans.fritz@honk.com","","","","cf1","cf2",""
-"org_name","salutation","title","n_given","n_family","role","adr_one_street","adr_one_postalcode","adr_one_locality","adr_one_countryname","tel_work","tel_fax","tel_cell","email","tel_fax_home","tel_home","email_home","customfield1","customfield2"\r
-"effect gmbh","Herr","Dr.","Jörg","Heinz","Geschäftsführer","Str. 25","21222","Köln","DE","022324321","","","joerg.heinz@honk.com","022324322","022324323","joerg@home.com","","cf2-2"\r
-"effect gmbh","Herr","","Hans","Fritz","Technical Lead","Str. 25","21222","Köln","DE","022324321","","","hans.fritz@honk.com","","","","cf1","cf2"\r
+"org_name","salutation","title","n_given","n_family","role","adr_one_street","adr_one_postalcode","adr_one_locality","adr_one_countryname","tel_work","tel_fax","tel_cell","email","tel_fax_home","tel_home","email_home","customfield1","customfield2","customfield3"
+"effect gmbh","Herr","Dr.","Jörg","Heinz","Geschäftsführer","Str. 25","21222","Köln","DE","022324321","","","joerg.heinz@honk.com","022324322","022324323","joerg@home.com","","cf2-2",""
+"effect gmbh","Herr","","Hans","Fritz","Technical Lead","Str. 25","21222","Köln","DE","022324321","","","hans.fritz@honk.com","","","","cf1","cf2",""
$ownField = $this->__get($fieldName);
$recordField = $_record->$fieldName;
-
+
+ if ($fieldName == 'customfields' && is_array($ownField) && is_array($recordField)) {
+ // special handling for customfields, remove empty customfields from array
+ foreach (array_keys($recordField, '', true) as $key) {
+ unset($recordField[$key]);
+ }
+ foreach (array_keys($ownField, '', true) as $key) {
+ unset($ownField[$key]);
+ }
+ }
+
if (in_array($fieldName, $this->_datetimeFields)) {
if ($ownField instanceof DateTime
&& $recordField instanceof DateTime) {