/** * Flush the Job to the Salesforce * * @return void * * @throws \RuntimeException When user is not authenticated * @throws \LogicException When a job is not set */ public function flush() { if (!$this->client->isAuthenticated()) { throw new \RuntimeException('You must be authenticated!'); } if (!$this->job instanceof Job) { throw new \LogicException('You must set a Job for this bulk'); } $this->httpClient->setHeaders($this->getAuthorizationHeader()); $this->flushJob(); $this->flushBatches(); }
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()); }