Skip to content

Commit ab962ce

Browse files
charlotteliangpaulb777
authored andcommitted
use instanceIDForTest for instance init in unit tests (#2239)
* use instanceIDForTest for instance init in unit tests * looks like realInstanceID is not needed * Get InstanceID from SpecsStaging to fix tests
1 parent 8289c6c commit ab962ce

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

Example/Messaging/Tests/FIRMessagingTest.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626

2727
extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;
2828

29+
@interface FIRInstanceID (ExposedForTest)
30+
31+
+ (FIRInstanceID *)instanceIDForTests;
32+
33+
@end
34+
2935
@interface FIRMessaging ()
3036
+ (FIRMessaging *)messagingForTests;
3137

@@ -45,7 +51,6 @@ @interface FIRMessagingTest : XCTestCase
4551
@property(nonatomic, readonly, strong) FIRMessaging *messaging;
4652
@property(nonatomic, readwrite, strong) id mockMessaging;
4753
@property(nonatomic, readwrite, strong) id mockInstanceID;
48-
@property(nonatomic, readwrite, strong) id realInstanceID;
4954
@property(nonatomic, readwrite, strong) id mockFirebaseApp;
5055

5156
@end
@@ -55,19 +60,17 @@ @implementation FIRMessagingTest
5560
- (void)setUp {
5661
[super setUp];
5762
_messaging = [FIRMessaging messagingForTests];
63+
_messaging.instanceID = [FIRInstanceID instanceIDForTests];
5864
_mockFirebaseApp = OCMClassMock([FIRApp class]);
5965
OCMStub([_mockFirebaseApp defaultApp]).andReturn(_mockFirebaseApp);
6066
_mockInstanceID = OCMPartialMock(self.messaging.instanceID);
61-
_realInstanceID = self.messaging.instanceID;
62-
self.messaging.instanceID = self.mockInstanceID;
6367
[[NSUserDefaults standardUserDefaults]
6468
removePersistentDomainForName:[NSBundle mainBundle].bundleIdentifier];
6569
}
6670

6771
- (void)tearDown {
6872
self.messaging.shouldEstablishDirectChannel = NO;
6973
self.messaging.defaultFcmToken = nil;
70-
self.messaging.instanceID = self.realInstanceID;
7174
self.messaging.apnsTokenData = nil;
7275
[_mockMessaging stopMocking];
7376
[_mockInstanceID stopMocking];

Example/Podfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Uncomment the next two lines for pre-release testing
1+
# Uncomment the next two lines for pre-release testing on internal repo
22
#source 'sso://cpdc-internal/firebase'
33
#source 'https://github.com/CocoaPods/Specs.git'
44

5+
# Uncomment the next two lines for pre-release testing on public repo
6+
source 'https://github.com/Firebase/SpecsStaging.git'
7+
source 'https://github.com/CocoaPods/Specs.git'
8+
59
use_frameworks!
610

711
pod 'FirebaseAnalyticsInterop', :path => '../'

FirebaseMessaging.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ device, and it is completely free.
3939
s.framework = 'SystemConfiguration'
4040
s.dependency 'FirebaseAnalyticsInterop', '~> 1.1'
4141
s.dependency 'FirebaseCore', '~> 5.1'
42-
s.dependency 'FirebaseInstanceID', '~> 3.0'
42+
s.dependency 'FirebaseInstanceID', '~> 3.4'
4343
s.dependency 'GoogleUtilities/Reachability', '~> 5.2'
4444
s.dependency 'GoogleUtilities/Environment', '~> 5.2'
4545
s.dependency 'Protobuf', '~> 3.1'

scripts/pod_lib_lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fi
3737
# or Core APIs change. GoogleUtilities.podspec and FirebaseCore.podspec should be
3838
# manually pushed to a temporary Specs repo. See
3939
# https://guides.cocoapods.org/making/private-cocoapods.
40-
ALT_SOURCES="--sources=https://github.com/paulb777/Specs.git,https://github.com/CocoaPods/Specs.git"
40+
ALT_SOURCES="--sources=https://github.com/Firebase/SpecsStaging.git,https://github.com/CocoaPods/Specs.git"
4141

4242
podspec="$1"
4343
if [[ $# -gt 1 ]]; then

0 commit comments

Comments
 (0)