+ Start a Discussion
huskerwendyhuskerwendy 

Public Knowledge Test Class error

I'm trying to deploy Public Knowledge to our production instance from the Sandbox. I'm receiving an error on live that I'm not getting in the Sandbox and I dont' know what's causing the error. The Business Hours are set up the same between the Sandbox and Production. I'm not really sure what is causing the error or how to fix it. Can someone please help? Thanks!

This is the error:
pkb_mobile_Test.test_MobilePhoneCall(), Details: System.AssertException: Assertion Failed: Expected: true, Actual: false Class.pkb_mobile_Test.test_MobilePhoneCall: line 843, column 1

here's the code from the pkb_mobile_Test.apxc class that is causing the error:
@isTest(SeeAllData=true)
    static void test_MobilePhoneCall(){
       PKB__c pkS = populateSetup();
  	   BusinessHours bH = [Select Id from BusinessHours where IsDefault = true limit 1];

       DateTime timeToSend = businesshours.addGmt(bH.id, system.now(), 1000 * 60);
       map<String,String> resp = (map<String,String>) pkb_mobile_controller.getPhoneCallAvailable(timeToSend);
    	  system.assertEquals( 'true', resp.get('available') );

    }


    public static PKB__c populateSetup() {
        // create custom settings collection based on siteName
        PKB__c pkb = new PKB__c();
        pkb.Name = siteName;
        pkb.MCategory_Group_1__c = 'group1';
        pkb.MCategory_Group_2__c = 'group2';
        pkb.MCategory_Group_3__c = 'group3';
        pkb.MRoot_Category_1__c = 'root1';
        pkb.MRoot_Category_2__c = 'root2';
        pkb.MRoot_Category_3__c = 'root3';

        pkb.Create_Contact_and_Account__c = false;
        pkb.Contact_Us_Available__c = false;
        pkb.Display_Article_Summary__c = true;
        pkb.Multi_Language_Enabled__c = true;
        pkb.Popular_Articles_Size__c = 2;
        pkb.Related_Articles_Size__c = 2;
        pkb.Results_Page_Size__c = 2;
        pkb.Selected_Languages__c = 'en_US';
        pkb.MEnableCall__c = true;
        pkb.MBusinessHours__c = 'testPkbMT';
        pkb.MPhoneNumber__c = '8774478936';

        insert pkb;
        if (kavObj != null){

            //insert records on the KAV fields custom setting
            Id kavID = String.valueOf(kavObj.get('id'));
            Schema.SObjectType token = kavID.getSObjectType();
            Schema.DescribeSObjectResult dr = token.getDescribe();
            set<String> allFields = token.getDescribe().fields.getMap().keySet();
            list<String> listFields = new list<String>();
            listFields.addAll(allFields);
            String layout = String.join(listFields,',');
            Integer cutAt = layout.lastIndexOf(',', 50);
            pkb_Ka__c pkF = new pkb_Ka__c();
            pkF.layout__c = layout.substring(0,cutAt);
            pkF.apiName__c  =  objType;
            pkF.pkb__c = pkb.Id;
            pkF.Name ='RAMDOM_UNUSED_NAME';
            insert pkF;
        }


        system.debug(logginglevel.INFO,'\n\n\n=======\n pkb_mobile_Test populateSetup ['+siteName+'] \n >>>Contact_Us_Available__c : '+pkb.Contact_Us_Available__c);

        return pkb;
    }

Here is the Controller code that the test class is using
//Bussines hours / call available
    public static Object getPhoneCallAvailable(DateTime d){
        map<String,String> ret = new map<String,String>();

        pkb_mobile_proxy.ResponseItem r = pkb_mobile_controller.getCurrentSiteSetUp();
        String businessHour = r.setup.get('businessHours');
        if ( Test.isRunningTest() ) businessHour = pkb_mobile_Test.getTestBusinessHourName();

        Boolean isCallEnabled =  pkb_mobile_controller.isPhoneCallAvailable( d,  businessHour);

        if (isCallEnabled){
             if ( r.setup.get('phoneNumber') != null ){
                ret.put('available',String.valueOf(true));
                ret.put('number',r.setup.get('phoneNumber'));
            }else{
                ret.put('available',String.valueOf(false));
            }
        }else{
            ret.put('available',String.valueOf(false));
        }
        return ret;
    }

 
huskerwendyhuskerwendy
this is the line that is cuasing the error. Line 8 in the test_MobilePhoneCall() method.
 system.assertEquals( 'true', resp.get('available') );