-
-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-16526 [needs-review] Financial ACL API tests #7818
Conversation
Edzelopez
commented
Feb 16, 2016
- CRM-16526: ACLs for Financial Types
@@ -44,8 +44,28 @@ | |||
* api result array | |||
*/ | |||
function civicrm_api3_line_item_create($params) { | |||
$params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params, TRUE); | |||
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |||
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this go in the BAO? the api should just be a wrapper for the BAO
Great to see the test! What is worrying me about all this extra logic going into the api layer is that apart from being against our general principle of trying to put all logic in the BAO layer you are also creating future-you or someone like you work because api v4 will drop all of the api layer create logic and you will either have to move it to the BAO at that point or negotiate some exception on api v4. Of course moving it to the BAO is unit tested but it would require at least some UI click around checks too to check nothing wierd is happening. |
I agree @eileenmcnaughton, but I checked and the lineitem get API does not rely on the BAO. It just does a basic DAO get (). So unless we change that, we can't really modify the way the line items are being retrieved. Of course if there's anot her way this can be done please let me know :) |
I was looking more at create than get (which does have a BAO function to add things to). The issue with get leveraging ACLs has recently been looked at by @colemanw and he can hopefully advise as to whether that approach is mature enough to add here. I'm also kind of aware that you used an ACL approach that is more drupal-like than CiviCRM-like but I didn't dig into that side of it - I suspect the difference won't have much impact thought |
Thanks for the suggestion @eileenmcnaughton |
@@ -67,6 +69,12 @@ public static function create(&$params) { | |||
if ($id) { | |||
unset($params['entity_id'], $params['entity_table']); | |||
} | |||
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { | |||
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op); | |||
if (!in_array($params['financial_type_id'], array_keys($types))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to only do this if check_permissions = TRUE
Jenkins, retest this please |
992b95f
to
3423f5a
Compare
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
… for line item ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
…n if even one is non-permissioned ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
…sioned line items for contribution ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
…PI for create ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
… added only if ACL is enabled ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
… for lineitems ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
3454dc3
to
50d8cef
Compare
Jenkins, retest this please |
…tead of logic in API ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
Hi @eileenmcnaughton , We are having an issue with getting Jenkins to pass. We were wondering if you have any idea what we are doing wrong here and would very much appreciate ideas as to how to make sure that there is consistency of our tests between our local machine and Jenkins. |
See if it works when running api_v3_AllTests - probably some other test is leaving something behind that is messing with your test so it fails when they all run but not with only some. If it does fail there is a clever way to run selectively but I just delete around half the test classes locally & re-run until I've homing in on the clashing class |
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526
@eileenmcnaughton you were right, there was a caching issue with one of the static variables that was failing when run with the other tests. I've fixed it now. |
@eileenmcnaughton would you be able to merge this for us? It's been waiting for over a week. |
CRM-16526 [needs-review] Financial ACL API tests