/** * Execute a Query in Salesforce API * * @param string $soql The Salesforce Object Query Language to execute * * @return \SimpleXMLElement */ public function query($soql) { $queryString = array('q' => $soql); $requestEvent = new QueryEvent($this->endpoint . 'query', $queryString); $this->client->dispatch(Events::QUERY, $requestEvent); $this->httpClient->setHeaders($this->getAuthorizationHeader()); $response = $this->httpClient->get('query', $queryString); $response = ResponseMediator::getContent($response); $this->client->dispatch(Events::RESPONSE, new ResponseEvent($requestEvent, $response->asXML())); return $response; }
public function testShouldBeAuthenticated() { $login = '******'; $password = '******'; $token = 'xpto321'; $httpClient = $this->getHttpClientMock(); $loginResult = $this->getLoginResultMock(); $loginResult->method('getServerUrl')->willReturn('https://cs21.salesforce.com/services/Soap/c/32.0/'); $soapClient = $this->getSoapClientMock(); $soapClient->expects($this->once())->method('authenticate')->with($login, $password, $token)->willReturn($loginResult); $client = new Client($this->getWSDLPath(), $httpClient); $client->setSoapClient($soapClient); $client->authenticate($login, $password, $token); $this->assertTrue($client->isAuthenticated()); }
/** * Flush all job batches * * @return void */ protected function flushBatches() { $batches = $this->job->getBatches(); foreach ($batches as $i => $batch) { $url = sprintf('job/%s/batch', $this->job->getId()); $requestEvent = new CreateBatchEvent($this->client->getRestEndpoint() . $url, $batch->asXML()); $this->client->dispatch(Events::CREATE_BATCH, $requestEvent); $response = $this->httpClient->post($url, $batch->asXML()); $response = ResponseMediator::getContent($response); $this->client->dispatch(Events::RESPONSE, new ResponseEvent($requestEvent, $response->asXML())); $batches[$i]->fromXml($response); } }