/** * 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 testShouldLoadDataFromXml() { $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <id>750D0000000002lIAA</id> <operation>insert</operation> <object>Account</object> <createdById>005D0000001ALVFIA4</createdById> <createdDate>2009-04-14T18:15:59.000Z</createdDate> <systemModstamp>2009-04-14T18:15:59.000Z</systemModstamp> <state>Open</state> <contentType>XML</contentType> </jobInfo> '); $job = new Job('Account'); $job->fromXml($xml); $this->assertEquals('750D0000000002lIAA', $job->getId()); $this->assertEquals('Open', $job->getState()); }