Im trying to setup a simple test to show the "sharing set" is working properly.
I a communities sharign set that says
Account | User:Account = Account:Id | Read/Write
and I know this works cause I can verify it in my app, but when i tried to write a simple test to check not having any luck?
Theres a utility class that i wont post here but I can verify from the debug logs that they two users do share an account and yet one cant see the others customers?
Is it an known issue that sharing sets arent evaluated in apex tests?
@isTest static void sharingInsideOrg() {
list<Customer__c> allCustomers = new list<Customer__c>();
Contact contact;
User u = TestUtility.setupTestCoach();
System.runAs(u) {
contact = [Select Id, AccountId from Contact where ID =:u.ContactId ];
System.Debug('*** User 1:'+contact.AccountId);
Customer__c c = TestUtility.setupTestCustomer();
c.Name = 'Customer1';
c.Coach__c = u.ContactId;
insert c;
Meeting__c m = TestUtility.createMeeting();
m.Customer__c = c.Id;
insert m;
allCustomers = [Select Id from Customer__c ];
System.assertEquals(1, allCustomers.size());
}
// create a second user with the same organization
User u2 = TestUtility.setupTestCoachSameOrg(u.ContactId);
System.runAs(u2) {
contact = [Select Id, AccountId from Contact where ID =:u2.ContactId ];
System.Debug('*** User 2:'+contact.AccountId);
allCustomers = [Select Id from Customer__c ];
System.assertEquals(1, allCustomers.size());
}
}