Пример #1
0
 /**
  * @param $lastName Last name for new lead
  *
  * @return Lead
  */
 private function createLeadFromWebForm($lastName)
 {
     $postData = array('last_name' => $lastName, 'campaign_id' => $this->campaign->id);
     // Send request for add lead
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $GLOBALS['sugar_config']['site_url'] . '/index.php?entryPoint=WebToLeadCapture');
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $response = curl_exec($ch);
     $this->assertEquals('Thank You For Your Submission.', $response);
     curl_close($ch);
     // Fetch last created lead
     $createdLead = new Lead();
     $query = 'SELECT * FROM leads ORDER BY date_entered DESC LIMIT 1';
     $createdLead->fromArray($this->db->fetchOne($query));
     return $createdLead;
 }