Skip to content

Commit 5003be4

Browse files
authored
[FCM] Fix cases of multiple stubs on the same method on a mock (#14656)
1 parent 470b0b0 commit 5003be4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

FirebaseMessaging/Tests/UnitTests/FIRMessagingRemoteNotificationsProxyTest.m

+7-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ @interface FIRMessagingRemoteNotificationsProxyTest : XCTestCase
128128
@property(nonatomic, strong) id mockProxyClass;
129129
@property(nonatomic, strong) id mockMessaging;
130130
@property(nonatomic, strong) id mockUserNotificationCenter;
131+
@property(nonatomic, strong) UNUserNotificationCenter *currentNotificationCenter;
131132

132133
@end
133134

@@ -147,8 +148,13 @@ - (void)setUp {
147148
OCMStub([_mockProxyClass sharedProxy]).andReturn(self.proxy);
148149
if (@available(macOS 10.14, iOS 10.0, *)) {
149150
_mockUserNotificationCenter = OCMClassMock([UNUserNotificationCenter class]);
151+
_currentNotificationCenter = _mockUserNotificationCenter;
150152
OCMStub([_mockUserNotificationCenter currentNotificationCenter])
151-
.andReturn(_mockUserNotificationCenter);
153+
.andDo(^(NSInvocation *invocation) {
154+
__autoreleasing UNUserNotificationCenter *currentNotificationCenter =
155+
self->_currentNotificationCenter;
156+
[invocation setReturnValue:&currentNotificationCenter];
157+
});
152158
}
153159
}
154160

0 commit comments

Comments
 (0)