1

Starting to think about unit testing access control permission logic in API calls.

Is there an established pattern for this?

Within CiviUnitTestCase and ACLPermissionTest there are these snips:

  • Setup: $config->userPermissionClass->permissions = array();
  • $this->createLoggedInUser(); (creates and masquerade as a user, returning the new users contactID)
  • $this->setPermissions($permissions)
  • $session = CRM_Core_Session::singleton(); $session->set('userID', $contactID);
  • $this->setupACL();
  • tearDown: $config = CRM_Core_Config::singleton(); unset($config->userPermissionClass->permissions);

(assuming $config = CRM_Core_Config::singleton())

I'm still staring at the bowl...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.