Skip to content

Commit

Permalink
[NFC] [TEST] cleanup, more use of return in ActivityTest
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jun 17, 2021
1 parent 183ca91 commit a2b87ac
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 110 deletions.
7 changes: 2 additions & 5 deletions Civi/Test/Api3TestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ public function callAPISuccessGetSingle($entity, $params, $checkAgainst = NULL)
}

/**
* This function exists to wrap api getValue function & check the result
* so we can ensure they succeed & throw exceptions without litterering the test with checks
* There is a type check in this
* This function wraps the getValue api and checks the result.
*
* @param string $entity
* @param array $params
Expand All @@ -261,15 +259,14 @@ public function callAPISuccessGetSingle($entity, $params, $checkAgainst = NULL)
* - object
*
* @return array|int
* @throws \CRM_Core_Exception
*/
public function callAPISuccessGetValue($entity, $params, $type = NULL) {
$params += [
'version' => $this->_apiversion,
];
$result = $this->civicrm_api($entity, 'getvalue', $params);
if (is_array($result) && (!empty($result['is_error']) || isset($result['values']))) {
throw new \CRM_Core_Exception('Invalid getvalue result' . print_r($result, TRUE));
$this->fail('Invalid getvalue result' . print_r($result, TRUE));
}
if ($type) {
if ($type === 'integer') {
Expand Down
Loading

0 comments on commit a2b87ac

Please sign in to comment.