If you create your users programmatically you can easily make them friends with one another.
https://developers.facebook.com/docs/graph-api/reference/v2.1/test-user/friends
#import "FBGraphObject.h"
@protocol FBTestGraphUser <FBGraphObject>
@property (nonatomic, readonly) NSString *id;
@property (nonatomic, readonly) NSString *access_token;
@property (nonatomic, readonly) NSString *login_url;
@property (nonatomic, readonly) NSString *email;
@property (nonatomic, readonly) NSString *password;
@property (nonatomic, retain) NSArray *friends;
@end
-(id<FBTestGraphUser>)createTestFacebook
{
NSString *appName = "";
NSString *userPrefix = [NSString stringWithFormat:@"%@User", appName];
NSString *facebookApplicationId = "";
NSString *facebookApplicationAccessToken = "";
NSString *url = [NSString stringWithFormat:@"https://graph.facebook.com/%@/accounts/test-users?installed=true&name=%@&locale=en_US&permissions=email,user_birthday,publish_actions&access_token=%@", facebookApplicationId, userPrefix, facebookApplicationAccessToken];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
NSURLResponse *response = nil;
NSError *error = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
return (id<FBTestGraphUser>)[FBGraphObject graphObjectWrappingDictionary:[data objectFromJSONData]];
}
-(void)deleteTestFacebookUser:(id<FBTestGraphUser>)testFacebookUser
{
NSLog(@"Deleting Facebook users...");
NSMutableArray* existingUsers = [NSMutableArray arrayWithArray:testFacebookUser.friends];
[existingUsers addObject:testFacebookUser];
NSOperationQueue* wipeUsers = [NSOperationQueue new];
[existingUsers enumerateObjectsUsingBlock:^(id<FBTestGraphUser> user, NSUInteger idx, BOOL *stop) {
[wipeUsers addOperationWithBlock:^{
[self deleteTestFacebookUser:user];
}];
}];
[wipeUsers waitUntilAllOperationsAreFinished];
NSLog(@"Done deleting Facebook users");
}
-(void)makeUser:(id<FBTestGraphUser>)userA friendsWithUser:(id<FBTestGraphUser>)userB {
// Don't try to parallelize this; you'll get unknown OAuth exceptions. -CS 2013-11-18
[self sendFriendRequestFrom:userA toUser:userB];
[self sendFriendRequestFrom:userB toUser:userA];
}
-(void)sendFriendRequestFrom:(id<FBTestGraphUser>)sender toUser:(id<FBTestGraphUser>)receiver {
NSString *url = [NSString stringWithFormat:@"https://graph.facebook.com/%@/friends/%@?access_token=%@", sender.id, receiver.id, sender.access_token];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
NSURLResponse *response = nil;
NSError *error = nil;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
}
-(void)deleteTestFacebookUser:(id<FBTestGraphUser>)testFacebookUser
{
NSString *url = [NSString stringWithFormat:@"https://graph.facebook.com/%@?access_token=%@", testFacebookUser.id, WBTestCaseFacebookAppID];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"DELETE"];
NSError *error = nil;
NSURLResponse *response = nil;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
}