@isTest(SeeAllData=true)
private class TestAttachment{
static testmethod void testattach(){
Account a = new Account(Name='newAcct');
Test.startTest();
insert a;
Test.stopTest();
System.debug('Account created: ' + a.Id);
Attachment attach=new Attachment();
attach.Name='Unit Test Attachment';
Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
attach.body=bodyBlob;
attach.parentId=a.Id;
attach.ContentType = 'application/msword';
attach.IsPrivate = false;
attach.Description = 'Test';
insert attach;
System.debug('Inserted: '+ attach.Id);
List<Account> acct = [SELECT id, Name,
(SELECT Id FROM CombinedAttachments)
FROM Account where id = :a.Id];
System.debug('Account Query : '+acct);
for(Account a1 : acct){
System.debug('Id: '+a1.Id + ' Name: '+a1.Name + ' CombAttach: '+ a1.CombinedAttachments);
System.assert(a1.CombinedAttachments.size()>0);
}
}
}
cheers!