function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
llisallisa 

Calling getContent() in Test class

Hello ,

i want to add a method in test class,but since it contain getContent(), it is giving an error.Methods defined as TestMethod do not support getContent call.
Please suggest me if there any way to call this getContent() method.

This is my method - 

public PageReference attachPdf() {
     if(common.NVL(Acc.Tier__c)<>''){
        PageReference pdf;
        if(Acc.Tier__c.equalsIgnoreCase('Distributor')){  
        pdf= Page.Doc_TD;
        }
        else if(Acc.Tier__c.equalsIgnoreCase('Wholesale')){  
        pdf= Page.Doc_WholeSale;
        }
        else if(Acc.Tier__c.equalsIgnoreCase('SMD')){  
        pdf= Page.Doc_SMD;
        }
        else{
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.Error, 'Not supported now. Please select a tier.');
        ApexPages.addMessage(myMsg); 
        return null;
        }
        pdf.getParameters().put('id', documentId);
        Blob pdfBlob = pdf.getContent();
        Attachment a = new Attachment(parentId = Acc.id, name=Acc.SMS_Customer__r.name + '_'+ Acc.SMS_Date__c.year()+'_v'+(attachments.size()+1)+ '.pdf', body = pdfBlob, Description='Generate Version');
        PageReference finalPage=new PageReference('/'+documentId);
        insert a;
        return finalPage;
        }else{
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.Error, 'Please Select Tier for Account ');
        ApexPages.addMessage(myMsg); 
        return null; 
        }
        
    }