You are here

public function TestRestClient::getRecordTypes in Salesforce Suite 8.3

Same name and namespace in other branches
  1. 8.4 src/Tests/TestRestClient.php \Drupal\salesforce\Tests\TestRestClient::getRecordTypes()
  2. 5.0.x src/Tests/TestRestClient.php \Drupal\salesforce\Tests\TestRestClient::getRecordTypes()

Hard-code record types for testing.

Overrides RestClient::getRecordTypes

File

src/Tests/TestRestClient.php, line 54

Class

TestRestClient
Test Salesforce REST client.

Namespace

Drupal\salesforce\Tests

Code

public function getRecordTypes($name = NULL, $reset = FALSE) {
  $json = json_decode(file_get_contents(__DIR__ . '/recordTypes.json'), JSON_OBJECT_AS_ARRAY);
  $result = new SelectQueryResult($json);
  $record_types = [];
  foreach ($result
    ->records() as $rt) {
    $record_types[$rt
      ->field('SobjectType')][$rt
      ->field('DeveloperName')] = $rt;
  }
  if ($name != NULL) {
    if (!isset($record_types[$name])) {
      throw new \Exception("No record types for {$name}");
    }
    return $record_types[$name];
  }
  return $record_types;
}