To check Custom Permission and Other Features   Check and modify the values of feature parameters, and to show or hide custom objects and custom permissions in your subscribers’ orgs.    Syntax:  FeatureManagement.checkPermission('CustomPermission_apiName'); Return Type: Boolean  Example :  public   static   Boolean havingCperm =   FeatureManagement. checkPermission( apiName); OR if( FeatureManagement. checkPermission( apiName) ){your logic}   ClickHere  for More Details.     For information about feature parameters, see “Get Started with the Feature Management App” in the  ISVforce Guide .  In TestClass  to assign PermissionSet Use:  PermissionSet   ps  = [SELECT  Id , Name  FROM  PermissionSet  WHERE  Name  =  'apiName' ]; PermissionSetAssignment   psa  =  new   PermissionSetAssignment ();  psa . AssigneeId  =  UserInfo . getUserId ();  psa . PermissionSetId  = ...
Everything about Salesforce