@@ -81,9 +81,9 @@ + (NSUserDefaults *)sharedUserDefaultsForBundleIdentifier:(NSString *)bundleIden
81
81
82
82
typedef NS_ENUM (NSInteger , RCNTestRCInstance) {
83
83
RCNTestRCInstanceDefault,
84
+ RCNTestRCNumTotalInstances, // TODO(mandard): Remove once OCMock issue is resolved (#4877).
84
85
RCNTestRCInstanceSecondNamespace,
85
86
RCNTestRCInstanceSecondApp,
86
- RCNTestRCNumTotalInstances
87
87
};
88
88
89
89
@interface RCNRemoteConfigTest : XCTestCase {
@@ -99,6 +99,8 @@ @interface RCNRemoteConfigTest : XCTestCase {
99
99
NSUserDefaults *_userDefaults;
100
100
NSString *_userDefaultsSuiteName;
101
101
NSString *_DBPath;
102
+ id _DBManagerMock;
103
+ id _userDefaultsMock;
102
104
}
103
105
@end
104
106
@@ -112,14 +114,14 @@ - (void)setUp {
112
114
113
115
// Always remove the database at the start of testing.
114
116
_DBPath = [RCNTestUtilities remoteConfigPathForTestDatabase ];
115
- id classMock = OCMClassMock ([RCNConfigDBManager class ]);
116
- OCMStub ([classMock remoteConfigPathForDatabase ]).andReturn (_DBPath);
117
+ _DBManagerMock = OCMClassMock ([RCNConfigDBManager class ]);
118
+ OCMStub ([_DBManagerMock remoteConfigPathForDatabase ]).andReturn (_DBPath);
117
119
_DBManager = [[RCNConfigDBManager alloc ] init ];
118
120
119
121
_userDefaultsSuiteName = [RCNTestUtilities userDefaultsSuiteNameForTestSuite ];
120
122
_userDefaults = [[NSUserDefaults alloc ] initWithSuiteName: _userDefaultsSuiteName];
121
- id userDefaultsClassMock = OCMClassMock ([RCNUserDefaultsManager class ]);
122
- OCMStub ([userDefaultsClassMock sharedUserDefaultsForBundleIdentifier: [OCMArg any ]])
123
+ _userDefaultsMock = OCMClassMock ([RCNUserDefaultsManager class ]);
124
+ OCMStub ([_userDefaultsMock sharedUserDefaultsForBundleIdentifier: [OCMArg any ]])
123
125
.andReturn (_userDefaults);
124
126
125
127
RCNConfigContent *configContent = [[RCNConfigContent alloc ] initWithDBManager: _DBManager];
@@ -193,7 +195,6 @@ - (void)setUp {
193
195
OCMStub ([_configFetch[i] fetchConfigWithExpirationDuration: 43200 completionHandler: OCMOCK_ANY])
194
196
.andDo (^(NSInvocation *invocation) {
195
197
void (^handler)(FIRRemoteConfigFetchStatus status, NSError *_Nullable error) = nil ;
196
- // void (^handler)(FIRRemoteConfigFetchCompletion);
197
198
[invocation getArgument: &handler atIndex: 3 ];
198
199
[_configFetch[i] fetchWithUserProperties: [[NSDictionary alloc ] init ]
199
200
completionHandler: handler];
@@ -225,6 +226,18 @@ - (void)setUp {
225
226
- (void )tearDown {
226
227
[_DBManager removeDatabaseOnDatabaseQueueAtPath: _DBPath];
227
228
[[NSUserDefaults standardUserDefaults ] removePersistentDomainForName: _userDefaultsSuiteName];
229
+ [_DBManagerMock stopMocking ];
230
+ _DBManagerMock = nil ;
231
+ [_userDefaultsMock stopMocking ];
232
+ _userDefaultsMock = nil ;
233
+ for (int i = 0 ; i < RCNTestRCNumTotalInstances; i++) {
234
+ [(id )_configInstances[i] stopMocking ];
235
+ [(id )_configFetch[i] stopMocking ];
236
+ }
237
+ [_configInstances removeAllObjects ];
238
+ [_configFetch removeAllObjects ];
239
+ _configInstances = nil ;
240
+ _configFetch = nil ;
228
241
[super tearDown ];
229
242
}
230
243
0 commit comments