|
13 | 13 | // See the License for the specific language governing permissions and |
14 | 14 | // limitations under the License. |
15 | 15 | // |
| 16 | + |
16 | 17 | #import "FUIFacebookAuthTest.h" |
| 18 | +#import <OCMock/OCMock.h> |
17 | 19 | #import <FBSDKCoreKit/FBSDKCoreKit.h> |
18 | 20 |
|
19 | | -@interface FBSDKLoginManagerTest : FBSDKLoginManager |
| 21 | +@interface FUIFacebookAuthTest () |
20 | 22 | @property(nonatomic) FBSDKLoginManagerLoginResult *result; |
21 | 23 | @property(nonatomic) NSError *error; |
22 | 24 | @end |
23 | 25 |
|
24 | | -@implementation FBSDKLoginManagerTest |
25 | | - |
26 | | -- (void)logInWithPermissions:(NSArray *)permissions |
27 | | - fromViewController:(UIViewController *)fromViewController |
28 | | - handler:(FBSDKLoginManagerLoginResultBlock)handler { |
29 | | - handler(self.result, self.error); |
30 | | -} |
31 | | -@end |
32 | | - |
33 | | - |
34 | 26 | @implementation FUIFacebookAuthTest |
35 | 27 |
|
36 | 28 | - (FBSDKLoginManager *)createLoginManager { |
37 | | - return [[FBSDKLoginManagerTest alloc] init]; |
| 29 | + id mock = OCMClassMock([FBSDKLoginManager class]); |
| 30 | + OCMStub( |
| 31 | + [mock logInWithPermissions:[OCMArg any] |
| 32 | + fromViewController:[OCMArg any] |
| 33 | + handler:[OCMArg any]] |
| 34 | + ).andDo(^(NSInvocation *invocation) { |
| 35 | + void (^completion)(FBSDKLoginManagerLoginResult *, NSError *); |
| 36 | + [invocation getArgument:&completion atIndex:4]; |
| 37 | + completion(self.result, self.error); |
| 38 | + }); |
| 39 | + return mock; |
38 | 40 | } |
39 | 41 |
|
40 | 42 | - (void)configureLoginManager:(FBSDKLoginManagerLoginResult *)result withError:(NSError *)error { |
41 | | - ((FBSDKLoginManagerTest *)_loginManager).result = result; |
42 | | - ((FBSDKLoginManagerTest *)_loginManager).error = error; |
| 43 | + self.result = result; |
| 44 | + self.error = error; |
43 | 45 | } |
44 | 46 |
|
45 | 47 | @end |
0 commit comments