I have written auraEnabled method using getGlobalDescribe on the "ObjectPermissions" object, not sure how can I cover this type of method. Also Please let me know if there is something good to check to write test methods for such standard things, ex - to cover userLicenses, permissionSetLicens etc.

  Set<String> sobjectNames = new Set<String>();
    for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() ){
       Schema.DescribeSObjectResult objResult = o.getDescribe(); 
   List<AggregateResult> plist = new List<AggregateResult>();
   plist = [SELECT Parent.Profile.Name, COUNT(SObjectType) Quantity FROM ObjectPermissions 
            WHERE (ParentId IN (SELECT PermissionSetId FROM PermissionSetAssignment)) 
            AND Parent.IsOwnedByProfile = true 
            AND PermissionsRead = true
            AND PermissionsCreate = false
            AND PermissionsDelete = false
            AND PermissionsEdit = false
            AND PermissionsModifyAllRecords = false
            AND PermissionsViewAllRecords = false
            AND (SObjectType IN :sobjectNames) 
            GROUP BY Parent.Profile.Name];

1 Answer 1


In your test you can simply call the method:

Map<String,List<Boolean>> actual = YourClassName.getProfileWithObjects(pfr);

as the @AuraEnabled annotation adds special handling provided by the platform rather than takes anything away from the static method call capability.


On testing calls that check things like licenses, those objects are probably 8n the category of data that is not isolated from unit tests. But also you cannot update those objects so you have to rely on the default set that is in an org and write your tests to match those.

  • Okay, got it and how can I cover the licence information fetching methods like I am fetching UserLicenses and permissionSetLicense. I have edit the question with that method ?
    – Ashutosh
    Commented Jul 26, 2018 at 10:37
  • @Ashutosh Can you re-instate your original question and either add to it or perhaps better add a new question? The idea of this site is to keep a record of both the questions and answers.
    – Keith C
    Commented Jul 26, 2018 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .