public function RestClientTest::testObjectDelete in Salesforce Suite 8.4
Same name and namespace in other branches
- 8.3 tests/src/Unit/RestClientTest.php \Drupal\Tests\salesforce\Unit\RestClientTest::testObjectDelete()
- 5.0.x tests/src/Unit/RestClientTest.php \Drupal\Tests\salesforce\Unit\RestClientTest::testObjectDelete()
@covers ::objectDelete
File
- tests/
src/ Unit/ RestClientTest.php, line 404
Class
- RestClientTest
- @coversDefaultClass \Drupal\salesforce\Rest\RestClient @group salesforce
Namespace
Drupal\Tests\salesforce\UnitCode
public function testObjectDelete() {
$this
->initClient(array_merge($this->methods, [
'apiCall',
]));
// 3 tests for objectDelete:
// 1. test that a successful delete returns null
// 2. test that a 404 response gets eaten
// 3. test that any other error response percolates.
$this->client
->expects($this
->exactly(3))
->method('apiCall');
$this->client
->expects($this
->at(0))
->method('apiCall')
->willReturn(NULL);
$exception404 = new RequestException('', new GuzzleRequest('GET', ''), new GuzzleResponse(404, [], ''));
$this->client
->expects($this
->at(1))
->method('apiCall')
->will($this
->throwException($exception404));
// Test the objectDelete throws any other exception.
$exceptionOther = new RequestException('', new GuzzleRequest('GET', ''), new GuzzleResponse(456, [], ''));
$this->client
->expects($this
->at(2))
->method('apiCall')
->will($this
->throwException($exceptionOther));
$this
->assertNull($this->client
->objectDelete('', ''));
$this
->assertNull($this->client
->objectDelete('', ''));
$this
->expectException(RequestException::class);
$this->client
->objectDelete('', '');
}