Lib_Test_Enterprise_UpsertTest

The Gravity Forms Salesforce Add-On Lib Test Enterprise UpsertTest class.

Defined (1)

The class is defined in the following location(s).

/lib/Force.com-Toolkit-for-PHP/unit_test/Lib/Test/Enterprise/UpsertTest.php  
  1. class Lib_Test_Enterprise_UpsertTest extends Lib_Test_TestAbstractEnterprise 
  2. public function getTestName() 
  3. return 'Upsert'; 
  4.  
  5. /** 
  6. * Extract from documentation: 
  7. * "On standard objects, this call can use the name of any field with  
  8. * the idLookup field property instead of the external ID." 
  9. */ 
  10. protected function _run() 
  11. // Get list of all objects of Contact type 
  12. /** 
  13. $query = 'SELECT Id, Name, FirstName, LastName, Email from Contact'; 
  14. print_r($this->_mySforceConnection->query($query)); 
  15. /**/ 
  16.  
  17. $objectType = 'Contact'; 
  18.  
  19. $createFields = array ( 
  20. ); 
  21.  
  22. $sObject = new stdClass(); 
  23. $sObject->FirstName = 'George'; 
  24. $sObject->LastName = 'Smith'; 
  25. $sObject->Phone = '510-555-5555'; 
  26. $sObject->BirthDate = '1927-01-25'; 
  27. $sObject->Email = 'test@test.com'; 
  28.  
  29. $createResponse = $this->_mySforceConnection->create(array($sObject), $objectType); 
  30. echo "Creating New Contact\r\n"; 
  31. print_r($createResponse); 
  32.  
  33. $sObject->FirstName = 'Bill'; 
  34. $sObject->LastName = 'Clinton'; 
  35.  
  36. $upsertResponse = $this->_mySforceConnection->upsert('Email', array ($sObject), $objectType); 
  37. echo "Upserting Contact (existing)\r\n"; 
  38. print_r($upsertResponse); 
  39.  
  40. $sObject->FirstName = 'John'; 
  41. $sObject->LastName = 'Smith'; 
  42. $sObject->Email = 'testNew@test.com'; 
  43.  
  44. echo "Upserting Contact (new)\n"; 
  45. $upsertResponse = $this->_mySforceConnection->upsert('Email', array ($sObject), $objectType); 
  46. print_r($upsertResponse);