/** * Flush the Job * * @TODO Add validation before send request * * @return void */ protected function flushJob() { $requestEvent = new CreateJobEvent($this->client->getRestEndpoint() . 'job', $this->job->asXML()); $this->client->dispatch(Events::CREATE_JOB, $requestEvent); try { $response = $this->httpClient->post('job', $this->job->asXML()); $response = ResponseMediator::getContent($response); } catch (\LogicException $e) { $this->client->dispatch(Events::REQUEST_ERROR, new ErrorEvent($this->httpClient->getBaseUrl(), $this->job->asXML(), $e->getMessage())); throw $e; } $this->client->dispatch(Events::RESPONSE, new ResponseEvent($requestEvent, $response->asXML())); $this->job->fromXml($response); }
public function testShouldClearEmptyXMLAttributes() { $job = new Job('Account'); $xml = $job->asXML(); $expectedXml = '<?xml version="1.0"?> <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <operation>insert</operation> <object>Account</object> <contentType>XML</contentType> </jobInfo> '; $this->assertXmlStringEqualsXmlString($expectedXml, $xml); }