I have a query on accounts with an inner query on ActivityHistory
string query;
query =' SELECT id,ownerid,o,';
query+=' (SELECT id,AccountId, WhatId,status,createdDate,activityDate FROM ActivityHistories)';
query += ' FROM account;
Then I have a for loop for the activity history:
for(ActivityHistory acctHist : historiesList){ //some stuff happens here}
When I write my tests creating An account/ contact and task which are all associated I can't get the test to enter that loop?
Here is the test:
account a1 = new account();
a1.name = 'Acct Test 1' + system.now()+1;
acctsToInsert.add(a1);
database.insert(acctsToInsert);
system.debug('***a1***' + a1);
contact c1 = new contact();
c1.AccountId = a1.Id;
c1.FirstName = 'C1 First Name';
c1.LastName = 'C1 Last Name';
contactsToInsert.add(c1);
database.insert(contactsToInsert);
system.debug('***C1***' + c1);
task t1 = new task();
t1.whatId = a1.id;
t1.whoId = c1.id;
t1.Type = 'Call - Outbound';
t1.status = 'Completed';
t1.activityDate = system.today();
t1.calltype = 'Outbound';
insert t1;
Test.StartTest(); CallClass = new CallClass(); Test.StopTest();
All of the system debugs show the relationships exist but the loop is still not entered.