public function RestClientTest::testGetRecordTypes in Salesforce Suite 8.4
Same name and namespace in other branches
- 8.3 tests/src/Unit/RestClientTest.php \Drupal\Tests\salesforce\Unit\RestClientTest::testGetRecordTypes()
- 5.0.x tests/src/Unit/RestClientTest.php \Drupal\Tests\salesforce\Unit\RestClientTest::testGetRecordTypes()
@covers ::getRecordTypes
File
- tests/
src/ Unit/ RestClientTest.php, line 457
Class
- RestClientTest
- @coversDefaultClass \Drupal\salesforce\Rest\RestClient @group salesforce
Namespace
Drupal\Tests\salesforce\UnitCode
public function testGetRecordTypes() {
$this
->initClient(array_merge($this->methods, [
'query',
]));
$sObjectType = $this
->randomMachineName();
$developerName = $this
->randomMachineName();
$rawQueryResult = [
'totalSize' => 1,
'done' => TRUE,
'records' => [
0 => [
'attributes' => [
'type' => 'Foo',
'url' => 'Bar',
],
'SobjectType' => $sObjectType,
'DeveloperName' => $developerName,
'Id' => $this->salesforce_id,
],
],
];
$recordTypes = [
$sObjectType => [
$developerName => new SObject($rawQueryResult['records'][0]),
],
];
$cache = (object) [
'created' => time(),
'data' => $recordTypes,
];
$this->cache
->expects($this
->at(1))
->method('get')
->willReturn(FALSE);
$this->cache
->expects($this
->at(2))
->method('get')
->willReturn($cache);
$this->cache
->expects($this
->at(3))
->method('get')
->willReturn($cache);
$this->client
->expects($this
->once())
->method('query')
->willReturn(new SelectQueryResult($rawQueryResult));
$this
->assertEquals($recordTypes, $this->client
->getRecordTypes());
$this
->assertEquals($recordTypes[$sObjectType], $this->client
->getRecordTypes($sObjectType));
$this
->assertFalse($this->client
->getRecordTypes('fail'));
}