|
1
|
|
|
<?php |
|
2
|
|
|
class Lib_Test_Partner_MergeTest extends Lib_Test_TestAbstractPartner |
|
3
|
|
|
{ |
|
4
|
|
|
public function getTestName() |
|
5
|
|
|
{ |
|
6
|
|
|
return 'Merge'; |
|
7
|
|
|
} |
|
8
|
|
|
|
|
9
|
|
|
protected function _run() |
|
10
|
|
|
{ |
|
11
|
|
|
$sObject = new SObject(); |
|
12
|
|
|
$sObject->type = 'Contact'; |
|
13
|
|
|
$fields = array ( |
|
14
|
|
|
'LastName'=>'Tran', |
|
15
|
|
|
'BirthDate'=> '1927-01-25', |
|
16
|
|
|
'Phone' => '510-555-5555', |
|
17
|
|
|
); |
|
18
|
|
|
$sObject->fields = $fields; |
|
19
|
|
|
|
|
20
|
|
|
$sObject2 = new SObject(); |
|
21
|
|
|
$sObject2->type = 'Contact'; |
|
22
|
|
|
$fields['LastName'] = 'Smith'; |
|
23
|
|
|
$fields['FirstName'] = 'Nick'; |
|
24
|
|
|
$sObject2->fields = $fields; |
|
25
|
|
|
|
|
26
|
|
|
$sObject3 = new SObject(); |
|
27
|
|
|
$sObject3->type = 'Contact'; |
|
28
|
|
|
$fields['Phone'] = '555-555-5555'; |
|
29
|
|
|
$sObject3->fields = $fields; |
|
30
|
|
|
|
|
31
|
|
|
echo "Create 3 contacts.\n"; |
|
32
|
|
|
$createResponse = $this->_mySforceConnection->create(array($sObject, $sObject2, $sObject3),'Lead'); |
|
33
|
|
|
|
|
34
|
|
|
print_r($createResponse); |
|
35
|
|
|
|
|
36
|
|
|
// Merge $sObject2 into $sObject |
|
37
|
|
|
$mergeRequest = new stdclass(); |
|
38
|
|
|
$sObject->Id = $createResponse[0]->id; |
|
39
|
|
|
$mergeRequest->masterRecord = $sObject; |
|
40
|
|
|
$mergeRequest->comments = 'My merge comments'; |
|
41
|
|
|
$mergeRequest->recordToMergeIds = array($createResponse[1]->id, $createResponse[2]->id); |
|
42
|
|
|
|
|
43
|
|
|
echo "Merge second and third contacts into the first contact.\n"; |
|
44
|
|
|
$mergeResponse = $this->_mySforceConnection->merge($mergeRequest); |
|
45
|
|
|
|
|
46
|
|
|
print_r($mergeResponse); |
|
47
|
|
|
} |
|
48
|
|
|
} |