setCreatedDate in Test Class
Fri Nov 29 2024 21:25:48 GMT+0000 (Coordinated Universal Time)
Saved by
@gbritgs
@isTest
static void testProcessCasesSuccess() {
List<RecordType> recordTypes2 = [SELECT Id FROM RecordType WHERE SObjectType = 'Case' AND DeveloperName IN ('Reclamacao', 'ProcessoLogistico')];
List<Case> cases = [SELECT Id, Status, CreatedDate, RecordTypeId FROM Case WHERE RecordTypeId IN :recordTypes2];
for(Case c : cases) {
Test.setCreatedDate(c.Id, DateTime.newInstance(2023,12,12));
c = [SELECT Id, CreatedDate, RecordType.Name, status, StatusDayCount__c FROM Case WHERE Id = :c.Id];
}
Test.startTest();
AutoCloseCases.processCases();
Test.stopTest();
}
content_copyCOPY
Comments