I am trying to write a test class to test an Apex class that uses FeedItem object. The Apex class checks if the FeedItem record has a BestCommentId and does some actions. A snippet of the test data that I am creating is as follows -
FeedItem fi = new FeedItem(Title = 'Feed Title',ParentId = parentId,Type = 'QuestionPost');
insert fi;
FeedComment fc = new FeedComment(CommentBody = 'Comment Body',FeedItemId = fi.Id);
insert fc;
fi.BestCommentId = fc.Id;
update fi;
I get an exception on fi.BestCommentId = fc.Id
line that says Field is not writeable: FeedItem.BestCommentId
. Is there a way to do this? Especially without using seeAllData=true
.