* @param array $params
* array of order params.
*
- * @return string
*/
public static function checkLineItems(&$params) {
$totalAmount = CRM_Utils_Array::value('total_amount', $params);
$params['total_amount'] = $lineItemAmount;
}
elseif ($totalAmount != $lineItemAmount) {
- return "Line item total doesn't match with total amount.";
+ throw new API_Exception("Line item total doesn't match with total amount.");
}
- return NULL;
}
}
),
),
);
- $error = CRM_Contribute_BAO_Contribution::checkLineItems($params);
- $this->assertEquals("Line item total doesn't match with total amount.", $error);
+ try {
+ $error = CRM_Contribute_BAO_Contribution::checkLineItems($params);
+ $this->fail("Missed expected exception");
+ }
+ catch (Exception $e) {
+ $this->assertEquals("Line item total doesn't match with total amount.", $e->getMessage());
+ }
$this->assertEquals(3, $params['line_items'][0]['line_item'][0]['financial_type_id']);
$params['total_amount'] = 300;
- $error = CRM_Contribute_BAO_Contribution::checkLineItems($params);
- $this->assertEquals(NULL, $error);
+ CRM_Contribute_BAO_Contribution::checkLineItems($params);
}
}